package octez-libs

  1. Overview
  2. Docs

Syslog primitives based on the syslog(3) function.

See RFC 3164 for more information.

type facility =
  1. | Auth
  2. | Authpriv
  3. | Cron
  4. | Daemon
  5. | FTP
  6. | Kernel
  7. | Local0
  8. | Local1
  9. | Local2
  10. | Local3
  11. | Local4
  12. | Local5
  13. | Local6
  14. | Local7
  15. | LPR
  16. | Mail
  17. | News
  18. | Syslog
  19. | User
  20. | UUCP
  21. | NTP
  22. | Security
  23. | Console

The various kinds of syslog output.

val facility_to_string : facility -> string
val facility_of_string_opt : string -> facility option

Converts from string. Possible string values are: "auth", "authpriv", "cron", "daemon", "ftp", "kernel", "local0", "local1", "local2", "local3", "local4", "local5", "local6", "local7", "lpr", "mail", "news", "syslog", "user", "uucp", "ntp", "security", "console"

exception Syslog_error of string
type t = {
  1. mutable fd : Lwt_unix.file_descr;
  2. tag : string;
  3. facility : facility;
  4. with_pid : bool;
  5. path : string;
}

A syslog logger

val create : tag:string -> ?path:string -> ?with_pid:bool -> facility -> t Lwt.t

Creates a syslog logger.

create tag ?path ?with_pid facility opens the socket or the file path and returns a syslog logger. Messages logged through this logger with syslog are prepended with tag and send to facility.

  • path default value is, if exists, in this order: "dev/log", "/var/run/syslog", ""
  • If with_pid is true (the default false), include the caller's PID in each message.
val format_message : ?max_buflen:int -> ?timestamp:float -> tag:string -> facility:facility -> with_pid:bool -> Tezos_event_logging.Internal_event.level -> string -> string

format_message ?max_buflen logger level message formats the given message depending on logger and level

  • max_buflen is the maximum length of the complete message after which text is replaced by .... Default to 1024 due to original standard.
  • timestamp is the timestamp to display. Uses Unix.time if not provided.
val syslog : ?max_buflen:int -> ?timestamp:float -> t -> Tezos_event_logging.Internal_event.level -> string -> unit Lwt.t

syslog ?max_buflen logger level message formats message (using format_msg) and sends the result to the logger file descriptor with the appropriate level.

val close : t -> unit Lwt.t

close logger closes the logger's file-descriptor. The logger cannot be used after a call to this function. A call to syslog logger ... would result in a raised exception of kind Unix.Unix_error.

OCaml

Innovation. Community. Security.