Module Async_unix.Log
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 ... endmodule Message : sig ... endmodule Rotation : sig ... endmodule Output : sig ... endmodule Blocking : sig ... endval sexp_of_t : t -> Ppx_sexp_conv_lib.Sexp.t
module type Global_intf = sig ... endAn interface for singleton logs.
module Make_global : functor () Global_intfThis functor can be called to generate "singleton" logging modules.
module Global : Global_intfPrograms 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.ttype.
val set_level_via_param : t -> unit Core.Command.Param.tSets the log level via a flag, if provided.
val set_level : t -> Level.t -> unitMessages sent at a level less than the current level will not be output.
val level : t -> Level.tReturns 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 -> unitChanges 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 listval set_on_error : t -> [ `Raise | `Call of Core.Error.t -> unit ] -> unitIf
`Raiseis given, then background errors raised by logging will be raised to the monitor that was in scope whencreatewas called. Errors can be redirected anywhere by providing`Call f.
val close : t -> unit Async_unix__.Import.Deferred.tAny call that writes to a log after
closeis called will raise.
val is_closed : t -> boolReturns true if
closehas been called.
val flushed : t -> unit Async_unix__.Import.Deferred.tReturns a
Deferred.tthat is fulfilled when the last message delivered totbefore the call toflushedis out the door.
val rotate : t -> unit Async_unix__.Import.Deferred.tInforms the current
Outputs to rotate if possible.
val create : level:Level.t -> output:Output.t list -> on_error:[ `Raise | `Call of Core.Error.t -> unit ] -> tCreates a new log. See
set_level,set_on_errorandset_outputfor more.
val raw : ?time:Core.Time.t -> ?tags:(string * string) list -> t -> ('a, unit, string, unit) Core.format4 -> 'aval debug : ?time:Core.Time.t -> ?tags:(string * string) list -> t -> ('a, unit, string, unit) Core.format4 -> 'aval info : ?time:Core.Time.t -> ?tags:(string * string) list -> t -> ('a, unit, string, unit) Core.format4 -> 'aval error : ?time:Core.Time.t -> ?tags:(string * string) list -> t -> ('a, unit, string, unit) Core.format4 -> 'aval printf : ?level:Level.t -> ?time:Core.Time.t -> ?tags:(string * string) list -> t -> ('a, unit, string, unit) Core.format4 -> 'aGeneralized printf-style logging.
val raw_s : ?time:Core.Time.t -> ?tags:(string * string) list -> t -> Core.Sexp.t -> unitval info_s : ?time:Core.Time.t -> ?tags:(string * string) list -> t -> Core.Sexp.t -> unitval error_s : ?time:Core.Time.t -> ?tags:(string * string) list -> t -> Core.Sexp.t -> unitval debug_s : ?time:Core.Time.t -> ?tags:(string * string) list -> t -> Core.Sexp.t -> unitval sexp : ?level:Level.t -> ?time:Core.Time.t -> ?tags:(string * string) list -> t -> Core.Sexp.t -> unitGeneralized sexp-style logging.
val string : ?level:Level.t -> ?time:Core.Time.t -> ?tags:(string * string) list -> t -> string -> unitLog 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.tsurround t message flogsmessageand a UUID once before callingfand again afterfreturns or raises. Iffraises, the second message will include the exception, andsurrounditself will re-raise the exception tagged withmessage. As usual, the logging happens only iflevelexceeds 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 -> 'aval would_log : t -> Level.t option -> boolwould_logreturns true if a message at the given log level would be logged if sent immediately.
module Reader : sig ... endmodule For_testing : sig ... end