Crate syslog_rfc5424 [] [src]

Parser for RFC 5424 Syslog messages. Not to be confused with the older RFC 3164 BSD Syslog protocol, which many systems still emit.

In particular, supports the Structured Data fields.

Usually, you'll just call the (re-exported) parse_message function with a stringy object.

Example

A simple syslog server

use syslog_rfc5424::parse_message;
use std::net::UdpSocket;
use std::str;

let s = UdpSocket::bind("127.0.0.1:10514").unwrap();
let mut buf = [0u8; 2048];
loop {
    let (data_read, _) = s.recv_from(&mut buf).unwrap();
    let msg = parse_message(str::from_utf8(&buf[0..data_read]).unwrap()).unwrap();
    println!("{:?} {:?} {:?} {:?}", msg.facility, msg.severity, msg.hostname, msg.msg);
}

Unimplemented Features

  • Theoretically, you can send arbitrary (non-unicode) bytes for the message part of a syslog message. Rust doesn't have a convenient way to only treat some of a buffer as utf-8, so I'm just not supporting that. Most "real" syslog servers barf on it anway.

Reexports

pub use parser::parse_message;

Modules

message

In-memory representation of a single Syslog message.

parser

Enums

SyslogFacility

Syslog facilities. Taken From RFC 5424, but I've heard that some platforms mix these around. Names are from Linux.

SyslogSeverity

Syslog Severities from RFC 5424.