A library for general logging.
Although this module is fully Async-safe it exposes almost no Deferreds. This is partially a design choice to minimize the impact of logging in code, and partially the result of organic design (i.e. older versions of this interface did the same thing).
A (limited) Blocking
module is supplied to accommodate the portion of a program that
runs outside of Async.
module Level : sig ... end
module Message : sig ... end
module Rotation : sig ... end
module Output : sig ... end
module Blocking : sig ... end
include sig ... end
val sexp_of_t : t ‑> Sexplib.Sexp.t
module Make_global : functor () Global_intf
This functor can be called to generate "singleton" logging modules
module Global : Global_intf
Programs that want simplistic single-channel logging can open this module. It provides a global logging facility to a single output type at a single level. More nuanced logging can be had by using the functions that operate on a distinct Log.t type.
returns the last level passed to set_level
, which will be the log level
checked as a threshold against the level of the next message sent.
changes the output type of the log, which can be useful when daemonizing. The new output type will be applied to all subsequent messages.
val set_on_error : t ‑> [ `Raise | `Call of Core.Error.t ‑> unit ] ‑> unit
if `Raise
is given then background errors raised by logging will be raised to the
monitor that was in scope when create
was called. Errors can be redirected anywhere
by providing `Call f
.
val close : t ‑> unit Async_unix__.Import.Deferred.t
any call that writes to a log after close
is called will raise.
val flushed : t ‑> unit Async_unix__.Import.Deferred.t
returns a Deferred.t that is fulfilled when the last message delivered to t before the call to flushed is out the door.
val rotate : t ‑> unit Async_unix__.Import.Deferred.t
informs the current Output
s to rotate if possible
val create : level:Level.t ‑> output:Output.t list ‑> on_error:[ `Raise | `Call of Core.Error.t ‑> unit ] ‑> t
create a new log. See set_level
, set_on_error
and set_output
for
more.
val raw : ?time:Core.Time.t ‑> ?tags:(string * string) list ‑> t ‑> ('a, unit, string, unit) Core.format4 ‑> 'a
raw
printf like logging for raw (no level) messages. Raw messages are still
output with a timestamp.
val debug : ?time:Core.Time.t ‑> ?tags:(string * string) list ‑> t ‑> ('a, unit, string, unit) Core.format4 ‑> 'a
debug
printf like logging at the `Debug log level
val info : ?time:Core.Time.t ‑> ?tags:(string * string) list ‑> t ‑> ('a, unit, string, unit) Core.format4 ‑> 'a
info
printf like logging at the `Info log level
val error : ?time:Core.Time.t ‑> ?tags:(string * string) list ‑> t ‑> ('a, unit, string, unit) Core.format4 ‑> 'a
error
printf like logging at the `Error log level
val printf : ?level:Level.t ‑> ?time:Core.Time.t ‑> ?tags:(string * string) list ‑> t ‑> ('a, unit, string, unit) Core.format4 ‑> 'a
printf
generalized printf style logging
val sexp : ?level:Level.t ‑> ?time:Core.Time.t ‑> ?tags:(string * string) list ‑> t ‑> Core.Sexp.t ‑> unit
sexp
log sexps directly
val string : ?level:Level.t ‑> ?time:Core.Time.t ‑> ?tags:(string * string) list ‑> t ‑> string ‑> unit
string
logging of string values
val surround_s : ?level:Level.t ‑> ?time:Core.Time.t ‑> ?tags:(string * string) list ‑> t ‑> Core.Sexp.t ‑> (unit ‑> 'a Async_unix__.Import.Deferred.t) ‑> 'a Async_unix__.Import.Deferred.t
surround t message f
logs message
and a UUID once before calling f
and again
after f
returns or raises. If f
raises, the second message will include the
exception, and surround
itself will re-raise the exception tagged with message
. As
usual, the logging happens only if level
exceeds the minimum level of t
.
val surroundf : ?level:Level.t ‑> ?time:Core.Time.t ‑> ?tags:(string * string) list ‑> t ‑> ('a, unit, string, (unit ‑> 'b Async_unix__.Import.Deferred.t) ‑> 'b Async_unix__.Import.Deferred.t) Core.format4 ‑> 'a
module Reader : sig ... end