Crate syslog [] [src]

Syslog

This crate provides facilities to send log messages via syslog. It supports Unix sockets for local syslog, UDP and TCP for remote servers.

Messages can be passed directly without modification, or in RFC 3164 or RFC 5424 format

The code is available on Github

Example

extern crate syslog;

use syslog::{Facility,Severity};

fn main() {
  match syslog::unix(Facility::LOG_USER) {
    Err(e)         => println!("impossible to connect to syslog: {:?}", e),
    Ok(writer) => {
      let r = writer.send(Severity::LOG_ALERT, "hello world");
      if r.is_err() {
        println!("error sending the log {}", r.err().expect("got error"));
      }
    }
  }
}

Structs

Logger

Main logging structure

SyslogError

Enums

Facility
Severity

Functions

init

Initializes logging subsystem for log crate

init_tcp

TCP Logger init function compatible with log crate

init_udp

UDP Logger init function compatible with log crate

init_unix

Unix socket Logger init function compatible with log crate

init_unix_custom

Unix socket Logger init function compatible with log crate and user provided socket path

tcp

returns a TCP logger connecting local and server

udp

returns a UDP logger connecting local and server

unix

Returns a Logger using unix socket to target local syslog ( using /dev/log or /var/run/syslog)

unix_custom

Returns a Logger using unix socket to target local syslog at user provided path

Type Definitions

Priority
StructuredData

RFC 5424 structured data