Module Global.Make

This function can be called to generate logging modules with the Log.t lazily instantiated, and prepopulated in the arguments.

Parameters

Signature

val log : Log.t Core.Lazy.t
val copy : ?level:Level.t -> ?on_error:[ `Call of Core.Error.t -> unit | `Raise ] -> ?output:Output.t list -> ?extra_tags:(string * string) list -> unit -> Log.t

Make a copy of this log, with potentially some settings changed, or potentially extra tags added to each line.

val level : unit -> Level.t
val set_level : Level.t -> unit
val set_output : Output.t list -> unit
val get_output : unit -> Output.t list
val set_on_error : [ `Raise | `Call of Core.Error.t -> unit ] -> unit
val get_time_source : unit -> Async_kernel.Synchronous_time_source.t
val set_time_source : [> Core.read ] Async_kernel.Synchronous_time_source.T1.t -> unit
module Transform : sig ... end
val has_transform : unit -> bool
val clear_transforms : unit -> unit
val set_transform : (Message_event.t -> Message_event.t option) option -> unit
  • deprecated [since 2024-10] Use [Log.Global.Transform.add] instead
val get_transform : unit -> (Message_event.t -> Message_event.t option) option
  • deprecated [since 2024-10] Getting the transform is not supported but transforms may cleared with [Log.Global.clear_transforms] or added to with [Log.Global.Transform.add]
val add_tags : tags:(string * string) list -> unit
val would_log : Level.t option -> bool
val set_level_via_param : ?default:Level.t -> unit -> unit Core.Command.Param.t

Sets the global 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.

Functions that operate on a given log. In this case they operate on a single log global to the module.

val raw : ?time:Core.Time_float.t -> ?tags:(string * string) list -> ('a, unit, string, unit) Core.format4 -> 'a
val info : ?time:Core.Time_float.t -> ?tags:(string * string) list -> ('a, unit, string, unit) Core.format4 -> 'a
val error : ?time:Core.Time_float.t -> ?tags:(string * string) list -> ('a, unit, string, unit) Core.format4 -> 'a
val debug : ?time:Core.Time_float.t -> ?tags:(string * string) list -> ('a, unit, string, unit) Core.format4 -> 'a
val flushed : unit -> unit Async_kernel.Deferred.t
val printf : ?level:Level.t -> ?time:Core.Time_float.t -> ?tags:(string * string) list -> ('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 -> Core.Sexp.t -> unit
val info_s : ?time:Core.Time_float.t -> ?tags:(string * string) list -> Core.Sexp.t -> unit
val error_s : ?time:Core.Time_float.t -> ?tags:(string * string) list -> Core.Sexp.t -> unit
val debug_s : ?time:Core.Time_float.t -> ?tags:(string * string) list -> Core.Sexp.t -> unit
val sexp : ?level:Level.t -> ?time:Core.Time_float.t -> ?tags:(string * string) list -> Core.Sexp.t -> unit

Generalized sexp-style logging.

val string : ?level:Level.t -> ?time:Core.Time_float.t -> ?tags:(string * string) list -> string -> unit

Log a string directly.

val structured_message : ?level:Level.t -> ?time:Core.Time_float.t -> ?tags:(string * string) list -> Ppx_log_types.Message_data.t -> Ppx_log_types.Message_source.t -> unit
val message : Message.t -> unit

Log a pre-created message.

val message_event : Message_event.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 -> 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 -> ('a, unit, string, (unit -> 'b Async_kernel.Deferred.t) -> 'b Async_kernel.Deferred.t) Core.format4 -> 'a
module For_testing : sig ... end
module For_async_shutdown : sig ... end

Used internally by other Async libraries.