package async_log
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=2dae248d74c23aa6a1e0bc38d5b34c975eb4dfbdf32f0970641b5befd8385720
doc/async_log.kernel/Async_log_kernel/Log/index.html
Module Async_log_kernel.Log
Source
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.
Sets the log level via a flag, if provided.
Messages sent at a level less than the current level will not be output.
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.
Changes the time source of the log, which controls the default timestamp on messages.
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.
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
.
Any call that writes to a log after close
is called will raise.
Returns a Deferred.t
that is fulfilled when the last message delivered to t
before the call to flushed
is out the door.
val 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_event.t -> Message_event.t) ->
unit ->
t
Creates a new log. See set_level
, set_on_error
, set_output
, set_time_source
, and set_transform
for more.
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.
val raw :
?time:Core.Time_float.t ->
?tags:(string * string) list ->
t ->
('a, unit, string, unit) Core.format4 ->
'a
val debug :
?time:Core.Time_float.t ->
?tags:(string * string) list ->
t ->
('a, unit, string, unit) Core.format4 ->
'a
val info :
?time:Core.Time_float.t ->
?tags:(string * string) list ->
t ->
('a, unit, string, unit) Core.format4 ->
'a
val error :
?time:Core.Time_float.t ->
?tags:(string * string) list ->
t ->
('a, unit, string, unit) Core.format4 ->
'a
val printf :
?level:Level.t ->
?time:Core.Time_float.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
val raw_s :
?time:Core.Time_float.t ->
?tags:(string * string) list ->
t ->
Core.Sexp.t ->
unit
val info_s :
?time:Core.Time_float.t ->
?tags:(string * string) list ->
t ->
Core.Sexp.t ->
unit
val error_s :
?time:Core.Time_float.t ->
?tags:(string * string) list ->
t ->
Core.Sexp.t ->
unit
val debug_s :
?time:Core.Time_float.t ->
?tags:(string * string) list ->
t ->
Core.Sexp.t ->
unit
val sexp :
?level:Level.t ->
?time:Core.Time_float.t ->
?tags:(string * string) list ->
t ->
Core.Sexp.t ->
unit
Generalized sexp-style logging.
val string :
?level:Level.t ->
?time:Core.Time_float.t ->
?tags:(string * string) list ->
t ->
string ->
unit
Log a string directly.
val structured_message :
?level:Level.t ->
?time:Core.Time_float.t ->
?tags:(string * string) list ->
t ->
Ppx_log_types.Message_data.t ->
Ppx_log_types.Message_source.t ->
unit
val surround_s :
on_subsequent_errors:[ `Call of exn -> unit | `Log | `Raise ] ->
?level:Level.t ->
?time:Core.Time_float.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
. on_subsequent_errors
is passed to the internal monitor as rest
argument. As usual, the logging happens only if level
exceeds the minimum level of t
.
val surroundf :
on_subsequent_errors:[ `Call of exn -> unit | `Log | `Raise ] ->
?level:Level.t ->
?time:Core.Time_float.t ->
?tags:(string * string) list ->
t ->
('a,
unit,
string,
(unit -> 'b Async_kernel.Deferred.t) ->
'b Async_kernel.Deferred.t)
Core.format4 ->
'a
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.