Module Message_templates_lwt.Lwt_logger

Lwt logger implementation

Lwt logger - async logger implementation

type t = {
  1. min_level : Message_templates.Level.t;
  2. sinks : (Lwt_sink.sink_fn * Message_templates.Level.t option) list;
  3. enrichers : (Message_templates.Log_event.t -> Message_templates.Log_event.t) list;
  4. filters : (Message_templates.Log_event.t -> bool) list;
  5. context_properties : (string * Yojson.Safe.t) list;
  6. source : string option;
}

Logger implementation type

val is_enabled : t -> Message_templates.Level.t -> bool

Check if a level is enabled

val passes_filters : t -> Message_templates.Log_event.t -> bool

Check if event passes all filters

Apply all enrichers to an event

Add context properties to an event

val write : t -> ?exn:exn -> Message_templates.Level.t -> string -> (string * Yojson.Safe.t) list -> unit Lwt.t

Core write method

val verbose : t -> ?exn:exn -> string -> (string * Yojson.Safe.t) list -> unit Lwt.t

Level-specific convenience methods

val debug : t -> ?exn:exn -> string -> (string * Yojson.Safe.t) list -> unit Lwt.t
val information : t -> ?exn:exn -> string -> (string * Yojson.Safe.t) list -> unit Lwt.t
val warning : t -> ?exn:exn -> string -> (string * Yojson.Safe.t) list -> unit Lwt.t
val error : t -> ?exn:exn -> string -> (string * Yojson.Safe.t) list -> unit Lwt.t
val fatal : t -> ?exn:exn -> string -> (string * Yojson.Safe.t) list -> unit Lwt.t
val for_context : t -> string -> Yojson.Safe.t -> t

Create a contextual logger with additional property

Add an enricher function

val for_source : t -> string -> t

Create a sub-logger for a specific source

val create : min_level:Message_templates.Level.t -> sinks:(Lwt_sink.sink_fn * Message_templates.Level.t option) list -> t

Create a logger

val flush : t -> unit Lwt.t

Flush all sinks

val close : t -> unit Lwt.t

Close all sinks