package syslog-message

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Module for parsing RFC 3164 Syslog messages

type facility =
  1. | Kernel_Message
  2. | User_Level_Messages
  3. | Mail_System
  4. | System_Daemons
  5. | Security_Authorization_Messages
  6. | Messages_Generated_Internally_By_Syslogd
  7. | Line_Printer_Subsystem
  8. | Network_News_Subsystem
  9. | UUCP_subsystem
  10. | Clock_Daemon
  11. | Security_Authorization_Messages_10
  12. | Ftp_Daemon
  13. | Ntp_Subsystem
  14. | Log_Audit
  15. | Log_Alert
  16. | Clock_Daemon_15
  17. | Local0
  18. | Local1
  19. | Local2
  20. | Local3
  21. | Local4
  22. | Local5
  23. | Local6
  24. | Local7
  25. | Invalid_Facility

The type for Facilities

val int_of_facility : facility -> int

Convert a facility into an integer

val facility_of_int : int -> facility

Converts an integer into a facility

val string_of_facility : facility -> string

Converts a facility into a string

type severity =
  1. | Emergency
  2. | Alert
  3. | Critical
  4. | Error
  5. | Warning
  6. | Notice
  7. | Informational
  8. | Debug
  9. | Invalid_Severity

The type for Severity levels

val int_of_severity : severity -> int

Converts a severity into an integer

val severity_of_int : int -> severity

Converts an integer into a severity

val string_of_severity : severity -> string

Converts a severity into a string

val string_of_timestamp : Ptime.t -> string

string_of_timestamp Converts a timestamp into a string

type ctx = {
  1. timestamp : Ptime.t;
  2. hostname : string;
  3. set_hostname : bool;
}

ctx provides additional information to the parse function in case one of the sub-parsers fails.

  • timestamp: A timestamp
  • hostname: Hostname, IPv4 or IPv6 address of the sender. "-" if unknown.
  • set_hostname: If true, the parse function will skip its hostname sub-parser and use the hostname from ctx instead.

set_hostname is automatically set by the timestamp sub-parser when it fails, because at this point it is no longer possible to determine the hostname from the input string.

val ctx_hostname : ctx -> string -> ctx

ctx_hostname sets a new hostname in ctx

val ctx_set_hostname : ctx -> ctx

ctx_set_hostname

type t = {
  1. facility : facility;
  2. severity : severity;
  3. timestamp : Ptime.t;
  4. hostname : string;
  5. message : string;
}

The type for Syslog messages

val pp_string : t -> string

pp_string returns a pretty-printed string of t

val pp : t -> unit

pp pretty-prints a t using print_string

val parse : ctx:ctx -> string -> t option

parses a string containing a Syslog message and returns an option t

val to_string : ?len:int -> t -> string

to_string returns a Syslog message of type t as string. The output string is truncated to 1024 bytes, which is the default of len. Setting len to 0, leaves the output string unmodified.

OCaml

Innovation. Community. Security.