Module Log_extendedSource

include module type of struct include Async.Log end
Sourcemodule Level = Async.Log.Level
Sourcemodule Message = Async.Log.Message
Sourcemodule Rotation = Async.Log.Rotation
Sourcemodule Output = Async.Log.Output
Sourcemodule Blocking = Async.Log.Blocking
Sourceval sexp_of_t : t -> Sexplib0.Sexp.t
Sourcemodule type Global_intf = Async.Log.Global_intf

An interface for singleton logs.

Sourcemodule Make_global = Async.Log.Make_global

This functor can be called to generate "singleton" logging modules.

Sourcemodule Global = Async.Log.Global

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.

Sourceval set_level_via_param : t -> unit Core.Command.Param.t

Sets the log level via a flag, if provided.

Sourceval set_level : t -> Level.t -> unit

Messages sent at a level less than the current level will not be output.

Sourceval 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.

Sourceval 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.

Sourceval get_output : t -> Output.t list

Changes the time source of the log, which controls the default timestamp on messages.

Sourceval set_time_source : t -> Async_kernel.Synchronous_time_source.t -> unit
Sourceval 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.

Sourceval set_transform : t -> (Message.t -> Message.t) option -> unit
Sourceval get_on_error : t -> [ `Raise | `Call of Core.Error.t -> 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.

Sourceval set_on_error : t -> [ `Raise | `Call of Core.Error.t -> unit ] -> unit
Sourceval close : t -> unit Async_kernel.Deferred.t

Any call that writes to a log after close is called will raise.

Sourceval is_closed : t -> bool

Returns true if close has been called.

Sourceval flushed : t -> unit Async_kernel.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.

Sourceval rotate : t -> unit Async_kernel.Deferred.t

Informs the current Outputs to rotate if possible.

Sourceval create : level:Level.t -> output:Output.t list -> on_error:[ `Raise | `Call of Core.Error.t -> unit ] -> ?time_source:Async_kernel.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, and set_transform for more.

Sourceval copy : t -> t

Creates a copy of a log, which has the same settings and logs to the same outputs.

Printf-like logging for messages at each log level or raw (no level) messages. Raw messages still include a timestamp.

Sourceval raw : ?time:Time_unix.t -> ?tags:(string * string) list -> t -> ('a, unit, string, unit) Core.format4 -> 'a
Sourceval debug : ?time:Time_unix.t -> ?tags:(string * string) list -> t -> ('a, unit, string, unit) Core.format4 -> 'a
Sourceval info : ?time:Time_unix.t -> ?tags:(string * string) list -> t -> ('a, unit, string, unit) Core.format4 -> 'a
Sourceval error : ?time:Time_unix.t -> ?tags:(string * string) list -> t -> ('a, unit, string, unit) Core.format4 -> 'a
Sourceval printf : ?level:Level.t -> ?time:Time_unix.t -> ?tags:(string * string) list -> t -> ('a, unit, string, unit) Core.format4 -> 'a

Generalized printf-style logging.

Sexp logging for messages at each log level or raw (no level) messages. Raw messages still include a timestamp

Sourceval raw_s : ?time:Time_unix.t -> ?tags:(string * string) list -> t -> Core.Sexp.t -> unit
Sourceval info_s : ?time:Time_unix.t -> ?tags:(string * string) list -> t -> Core.Sexp.t -> unit
Sourceval error_s : ?time:Time_unix.t -> ?tags:(string * string) list -> t -> Core.Sexp.t -> unit
Sourceval debug_s : ?time:Time_unix.t -> ?tags:(string * string) list -> t -> Core.Sexp.t -> unit
Sourceval sexp : ?level:Level.t -> ?time:Time_unix.t -> ?tags:(string * string) list -> t -> Core.Sexp.t -> unit

Generalized sexp-style logging.

Sourceval string : ?level:Level.t -> ?time:Time_unix.t -> ?tags:(string * string) list -> t -> string -> unit

Log a string directly.

Sourceval message : t -> Message.t -> unit

Log a pre-created message.

Sourceval surround_s : ?level:Level.t -> ?time:Time_unix.t -> ?tags:(string * string) list -> t -> Core.Sexp.t -> (unit -> 'a Async_kernel.Deferred.t) -> 'a Async_kernel.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.

Sourceval surroundf : ?level:Level.t -> ?time:Time_unix.t -> ?tags:(string * string) list -> t -> ('a, unit, string, (unit -> 'b Async_kernel.Deferred.t) -> 'b Async_kernel.Deferred.t) Core.format4 -> 'a
Sourceval 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 a transform set.

Sourcemodule Reader = Async.Log.Reader
Sourcemodule For_testing = Async.Log.For_testing
Sourcemodule Console : sig ... end
Sourcemodule Syslog : sig ... end
Sourcemodule Command : sig ... end