package mirage-logs

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

Parameters

Signature

type t
val run : t -> (unit -> 'a Lwt.t) -> 'a Lwt.t

run t fn installs the reporter t as the current Logs reporter and runs fn ().

If t has a ring buffer and fn returns an error then the contents of the ring are dumped to provide extra context (and Lwt.async_exception_hook is also wrapped, to dump the ring for asynchronous exceptions).

val set_reporter : t -> unit

set_reporter t installs t as log reporter.

val unset_reporter : t -> unit

unset_reporter t remove the resources used when t has been installed.

val create : ?ch:Stdlib.out_channel -> ?ring_size:int -> ?console_threshold:threshold_config -> Clock.t -> t

create ~ch () is a Logs reporter that logs to ch, with time-stamps provided by Clock.

If ring_size is provided then each message that reaches the reporter is also written to a ring buffer (with the given size).

If tracing is enabled then each log message that reaches the reporter is also written to the trace buffer.

If console_threshold is provided then any message at or above the returned threshold is also written to the console. If not provided, all messages reaching the reporter are printed.

If logs are written faster than the backend can consume them, the whole unikernel will block until there is space (so log messages will not be lost, but unikernels generating a lot of log output may run slowly).

val reporter : t -> Logs.reporter

reporter t retrieves the Logs.reporter value associated with t

val dump_ring : t -> Stdlib.out_channel -> unit

dump_ring t oc writes all entries in the ring buffer to oc and clears the ring. If t has no ring buffer, this function does nothing.