Module Imandrakit_log.Logger

Main logger

type level = Log_level.t
val equal_level : level -> level -> Ppx_deriving_runtime.bool
module Log_event = Log_event
module Output : sig ... end

Log output.

type t

Main logger. This obtains events from Logs and writes them to the current set of Output.t.

val shutdown : t -> unit
val as_reporter : t -> Logs.reporter
val null : unit -> t
val add_output : t -> Output.t -> unit
val to_outputs : Output.t list -> t

Sends events to each output in the list

val with_no_logger : unit -> (unit -> 'a) -> 'a

with_no_logger () f calls f() in a context where there is no logger. Useful to avoid logging loops.

val setup_level : ?default_level:level -> ?debug:bool -> ?log_level:level -> unit -> unit

Setup log level. It will use Info by default, unless the env var "DEBUG" is set or ~debug or ~log_level is passed.

debug takes precedence over log_level which takes precedence over the env.

  • parameter default_level

    the level used if nothing is specified

val setup_logger_to_stdout : unit -> unit

Setup a logger that emits on stdout

val setup_logger_to_stderr : unit -> unit

Setup a logger that emits on stderr

val setup_logger_to_LOG_FILE : ?filename:string -> unit -> (unit -> 'a) -> 'a

Setup a logger that emits into the file specified in filename or in "LOG_FILE" env, or no logger otherwise. This will cleanup at the end when the function returns.

module type LOG = sig ... end
val fence : unit -> unit

fence () waits for the logger to have written all already queued messages.

val mk_log_str : string -> (module LOG)

Create a new logger with the given source.

val all_sources : Logs.src Iter.t

Get all log sources

val setup_level_per_source : (string * level option) Iter.t -> unit

Set level for certain sources