Module Logs_syslog_mirage

Logs reporter via syslog using MirageOS

Please read Logs_syslog first.

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

UDP syslog

module Tcp (CLOCK : Mirage_clock.PCLOCK) (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) (CLOCK : Mirage_clock.PCLOCK)
  module LU = Logs_syslog_mirage.Udp(CLOCK)(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) (CLOCK : Mirage_clock.PCLOCK)
  module LT = Logs_syslog_mirage.Tcp(CLOCK)(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