JFLib

netpkt/syslog.rs#

Source: lib/netpkt/syslog.rs

syslog -- syslog messages over UDP as BSD and Linux systems (RFC 3164) and Cisco IOS send
them; RFC 5424 messages are recognised

  pri(facility, severity) / facility_of(pri) / severity_of(pri)
  SEV_* / FAC_*; severity_name ("notice"), facility_name ("local7")
  bsd(pri, ts, host, tag, text)      "<30>Oct 19 12:00:05 pc1 dhclient: bound to 10.0.1.10"
  ios(pri, seq, ts, text)            "<189>12: *Oct 19 12:00:05.123: %LINK-3-UPDOWN: ..."
  bsd_time(month, day, h, m, s)      "Oct  9 08:00:05" (day padded with a space)
  parse(b) -> Option<Msg>            priority and the rest; for RFC 3164 also the time,
                                     host and tag when they are there
SEV_EMERG: u8 = 0
SEV_ALERT: u8 = 1
SEV_CRIT: u8 = 2
SEV_ERR: u8 = 3
SEV_WARNING: u8 = 4
SEV_NOTICE: u8 = 5
SEV_INFO: u8 = 6
SEV_DEBUG: u8 = 7
FAC_KERN: u8 = 0
FAC_USER: u8 = 1
FAC_DAEMON: u8 = 3
FAC_AUTH: u8 = 4
FAC_SYSLOG: u8 = 5
FAC_LOCAL0: u8 = 16
FAC_LOCAL7: u8 = 23
  • fn pri(facility: u8, severity: u8) -> u8

  • fn facility_of(pri: u8) -> u8

  • fn severity_of(pri: u8) -> u8

  • fn severity_name(s: u8) -> &'static str

  • fn facility_name(f: u8) -> &'static str

  • fn bsd_time(month: u8, day: u8, h: u8, m: u8, s: u8) -> String "Oct 9 08:00:05" (RFC 3164 4.1.2)

  • fn bsd(pri: u8, ts: &str, host: &str, tag: &str, text: &str) -> Vec<u8> a message as Linux (rsyslog's traditional forward format) sends it

  • fn ios(pri: u8, seq: u32, ts: &str, text: &str) -> Vec<u8> a message as IOS sends it to a "logging host": counter, time ("*" in front while the clock is not synchronised), text ("%FAC-SEV-MNEMONIC: ...")

  • struct Msg a received message

    • pri: u8
    • rest: String -- everything after "<PRI>"
    • time: Option<String> -- RFC 3164: "Oct 19 12:00:05"
    • host: Option<String>
    • tag: Option<String>
    • text: String -- the text after the tag (or the rest)
  • fn parse(b: &[u8]) -> Option<Msg>

Source: docs/API.md in the JFLib repository.