Log_extendedSourceinclude module type of struct include Async.Log endinclude module type of struct include Async_log endinclude module type of Async_log_kernel.Logval sexp_of_t : t -> Sexplib0.Sexp.tval set_level_via_param :
?default:Async_log_kernel__.Level.t ->
t ->
unit Core.Command.Param.tSets the log level via a flag, if provided.
If default is not provided, the existing log level will be unchanged if the flag is not provided.
val set_level : t -> Async_log_kernel__.Level.t -> unitMessages sent at a level less than the current level will not be output.
val level : t -> Async_log_kernel__.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 -> Async_log_kernel__.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 -> Async_log_kernel__.Output.t listval get_time_source : t -> Async_kernel.Synchronous_time_source.tChanges the time source of the log, which controls the default timestamp on messages.
val set_time_source :
t ->
[> Core.read ] Async_kernel.Synchronous_time_source.T1.t ->
unitmodule Transform = Async.Log.TransformA transform is a function to be called on each log invocation *synchronously* that can be used to change things about the message at the time that they were written.
val has_transform : t -> boolval clear_transforms : t -> unitval set_transform :
t ->
(Async_log_kernel__.Message_event.t ->
Async_log_kernel__.Message_event.t option)
option ->
unitval get_transform :
t ->
(Async_log_kernel__.Message_event.t ->
Async_log_kernel__.Message_event.t option)
optionval add_tags : t -> tags:(string * string) list -> unitOne common transformation on message events is tagging every remaining message with a list of fixed tags.
add_tags t ~tags is shorthand for Transform.prepend t (Message_event.add_tags ~tags). (prepend in this case means these tags are added before any other transformation is applied, which we believe is more often wanted, e.g. if a later transform flattens the message and tags into a single rendered string.)
This is not idempotent - if you add the same tags twice, they'll be included twice in the resultant message.
val add_tags' : t -> tags:(string * string) list -> Transform.tLike add_tags except that a Transform.t is returned which one can call Transform.remove_exn with.
val 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.
val set_on_error : t -> [ `Raise | `Call of Core.Error.t -> unit ] -> unitval close : t -> unit Async_kernel.Deferred.tAny call that writes to a log after close is called will raise.
val is_closed : t -> boolReturns true if close has been called.
val flushed : t -> unit Async_kernel.Deferred.tReturns a Deferred.t that is fulfilled once the last message delivered to t before the call to flushed has been written and flushed by t's outputs.
Logs written via portable functions, such as Log.Portable.info, may not have been delivered to t yet when flushed is called. flushed only waits for messages that have already been delivered to t.
val create :
level:Async_log_kernel__.Level.t ->
output:Async_log_kernel__.Output.t list ->
on_error:[ `Raise | `Call of Core.Error.t -> unit ] ->
?time_source:[> Core.read ] Async_kernel.Synchronous_time_source.T1.t ->
?transform:
(Async_log_kernel__.Message_event.t -> Async_log_kernel__.Message_event.t) ->
unit ->
tCreates a new log. See set_level, set_on_error, set_output, set_time_source, and set_transform for more.
val create_null : unit -> tLog that drops messages sent to it, as if it wrote to /dev/null
val copy :
?level:Async_log_kernel__.Level.t ->
?on_error:[ `Call of Core.Error.t -> unit | `Raise ] ->
?output:Async_log_kernel__.Output.t list ->
?extra_tags:(string * string) list ->
t ->
tMake a copy of this log, with potentially some settings changed, or potentially extra tags added to each line.
module Control_event = Async.Log.Control_eventval control_events : t -> (Control_event.t @ local -> unit) Bus.Read_only.tA bus that may be subscribed to to get control events which happen to this t.
(In at least one case, this was used to watch for level changes and change a different Log.t's level in a different process in response.)
If you subscribe to this bus and your callback raises, the error will be ignored. It is recommended that you subscribe with Bus.Subscribe so that you may pass ~on_callback_raise there.
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 ->
'aval debug :
?time:Core.Time_float.t ->
?tags:(string * string) list ->
t ->
('a, unit, string, unit) Core.format4 ->
'aval info :
?time:Core.Time_float.t ->
?tags:(string * string) list ->
t ->
('a, unit, string, unit) Core.format4 ->
'aval warn :
?time:Core.Time_float.t ->
?tags:(string * string) list ->
t ->
('a, unit, string, unit) Core.format4 ->
'aval error :
?time:Core.Time_float.t ->
?tags:(string * string) list ->
t ->
('a, unit, string, unit) Core.format4 ->
'aval printf :
?level:Async_log_kernel__.Level.t ->
?time:Core.Time_float.t ->
?tags:(string * string) list ->
t ->
('a, unit, string, unit) Core.format4 ->
'aGeneralized 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 ->
unitval info_s :
?time:Core.Time_float.t ->
?tags:(string * string) list ->
t ->
Core.Sexp.t ->
unitval warn_s :
?time:Core.Time_float.t ->
?tags:(string * string) list ->
t ->
Core.Sexp.t ->
unitval error_s :
?time:Core.Time_float.t ->
?tags:(string * string) list ->
t ->
Core.Sexp.t ->
unitval debug_s :
?time:Core.Time_float.t ->
?tags:(string * string) list ->
t ->
Core.Sexp.t ->
unitval sexp :
?level:Async_log_kernel__.Level.t ->
?time:Core.Time_float.t ->
?tags:(string * string) list ->
t ->
Core.Sexp.t ->
unitGeneralized sexp-style logging.
val string :
?level:Async_log_kernel__.Level.t ->
?time:Core.Time_float.t ->
?tags:(string * string) list ->
t ->
string ->
unitLog a string directly.
val structured_message :
?level:Async_log_kernel__.Level.t ->
?time:Core.Time_float.t ->
?tags:(string * string) list ->
t ->
Ppx_log_types.Message_data.t ->
Ppx_log_types.Message_source.t ->
unitval enqueue_structured_message :
?level:Async_log_kernel__.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 @@ portableval message : t -> Async_log_kernel__.Message.t -> unitLog a pre-created message.
val message_event : t -> Async_log_kernel__.Message_event.t -> unitval surround_s :
?on_subsequent_errors:[ `Call of exn -> unit | `Log | `Raise ] ->
?level:Async_log_kernel__.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.tsurround 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:Async_log_kernel__.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 ->
'aval would_log : t -> Async_log_kernel__.Level.t option -> bool @@ portablewould_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.
module For_testing = Async.Log.For_testingmodule Level = Async.Log.Levelmodule Message_event = Async.Log.Message_eventmodule Global = Async.Log.Globalmodule Ppx_log_syntax = Async.Log.Ppx_log_syntax