Module Logs_syslog_mirage

Logs reporter via syslog using MirageOS

Please read Logs_syslog first.

module Udp (STACK : Tcpip.Stack.V4V6) : sig ... end

UDP syslog

module Tcp (STACK : Tcpip.Stack.V4V6) : sig ... end

TCP syslog

Example usage

To install a Mirage syslog reporter, sending via UDP to localhost, use the following snippet:

module Main (S : Tcpip.Stack.V4V6) = struct
  module LU = Logs_syslog_mirage.Udp(S)

  let start s _ =
    let ip = Ipaddr.V4 (Ipaddr.V4.of_string_exn "127.0.0.1") in
    let r = LU.create s ip ~hostname:"MirageOS.example" () in
    Logs.set_reporter r ;
    Lwt.return_unit
end

The TCP transport is very similar:

module Main (S : Tcpip.Stack.V4V6) = struct
  module LT = Logs_syslog_mirage.Tcp(S)

  let start s _ =
    let ip = Ipaddr.V4 (Ipaddr.V4.of_string_exn "127.0.0.1") in
    LT.create s ip ~hostname:"MirageOS.example" () >>= function
      | Ok r -> Logs.set_reporter r ; Lwt.return_unit
      | Error e -> Lwt.fail_invalid_arg e
end