Module Async_unix__.Log
module Level : sig ... end
module Message : sig ... end
module Rotation : sig ... end
module Output : sig ... end
module Blocking : sig ... end
val sexp_of_t : t -> Ppx_sexp_conv_lib.Sexp.t
module type Global_intf = sig ... end
An interface for singleton logs.
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.
val set_level_via_param : t -> unit Core.Command.Param.t
Sets the log level via a flag, if provided.
val set_level : t -> Level.t -> unit
Messages sent at a level less than the current level will not be output.
val level : t -> Level.t
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.
val set_output : t -> Output.t list -> unit
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 get_output : t -> Output.t list
val get_time_source : t -> Async_unix__.Import.Synchronous_time_source.t
Changes the time source of the log, which controls the default timestamp on messages.
val set_time_source : t -> Async_unix__.Import.Synchronous_time_source.t -> unit
val get_transform : t -> (Message.t -> Message.t) option
Changes the
transform
function within log. This allows you to *synchronously* change things about the message at the time that they were written.The transform function *will not* be called if the initial message is of a level that would not currently be logged.
The transform function *will* be called if even if there are no log outputs.
val set_transform : t -> (Message.t -> Message.t) option -> unit
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 whencreate
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 is_closed : t -> bool
Returns true if
close
has been called.
val flushed : t -> unit Async_unix__.Import.Deferred.t
Returns a
Deferred.t
that is fulfilled when the last message delivered tot
before the call toflushed
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 ] -> ?time_source:Async_unix__.Import.Synchronous_time_source.t -> ?transform:(Message.t -> Message.t) -> unit -> t
Creates a new log. See
set_level
,set_on_error
,set_output
,set_time_source
, andset_transform
for more.
val raw : ?time:Core.Time.t -> ?tags:(string * string) list -> t -> ('a, unit, string, unit) Core.format4 -> 'a
val debug : ?time:Core.Time.t -> ?tags:(string * string) list -> t -> ('a, unit, string, unit) Core.format4 -> 'a
val info : ?time:Core.Time.t -> ?tags:(string * string) list -> t -> ('a, unit, string, unit) Core.format4 -> 'a
val error : ?time:Core.Time.t -> ?tags:(string * string) list -> t -> ('a, unit, string, unit) Core.format4 -> 'a
val printf : ?level:Level.t -> ?time:Core.Time.t -> ?tags:(string * string) list -> t -> ('a, unit, string, unit) Core.format4 -> 'a
Generalized printf-style logging.
val raw_s : ?time:Core.Time.t -> ?tags:(string * string) list -> t -> Core.Sexp.t -> unit
val info_s : ?time:Core.Time.t -> ?tags:(string * string) list -> t -> Core.Sexp.t -> unit
val error_s : ?time:Core.Time.t -> ?tags:(string * string) list -> t -> Core.Sexp.t -> unit
val debug_s : ?time:Core.Time.t -> ?tags:(string * string) list -> t -> Core.Sexp.t -> unit
val sexp : ?level:Level.t -> ?time:Core.Time.t -> ?tags:(string * string) list -> t -> Core.Sexp.t -> unit
Generalized sexp-style logging.
val string : ?level:Level.t -> ?time:Core.Time.t -> ?tags:(string * string) list -> t -> string -> unit
Log a string directly.
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
logsmessage
and a UUID once before callingf
and again afterf
returns or raises. Iff
raises, the second message will include the exception, andsurround
itself will re-raise the exception tagged withmessage
. As usual, the logging happens only iflevel
exceeds the minimum level oft
.
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
val would_log : t -> Level.t option -> bool
would_log
returns true if a message at the given log level would be logged if sent immediately.This will return
false
if there are no outputs for the log, unless there is atransform
set.
module Reader : sig ... end
module For_testing : sig ... end