Module Message_templates.Logger

Logger interface - main logging interface

module type S = sig ... end

Logger signature

module type ENRICHER = sig ... end

Enricher signature - adds properties to log events

module type FILTER = sig ... end

Filter signature - determines if an event should be logged

type t

Logger type - opaque

Core Functions

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

Create a logger with minimum level and sinks (with optional per-sink level filtering)

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

Core write method

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

Check if a level is enabled

Level-specific Methods

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

Context and Enrichment

val for_context : t -> string -> Yojson.Safe.t -> t

Create a contextual logger with additional property

val with_enricher : t -> (Log_event.t -> Log_event.t) -> t

Add an enricher function

val for_source : t -> string -> t

Create a sub-logger for a specific source

Lifecycle

val flush : t -> unit

Flush all sinks

val close : t -> unit

Close all sinks

Helper Functions

val add_property : t -> string -> Yojson.Safe.t -> t

Helper to add a property enricher - alias for for_context

val add_min_level_filter : t -> Level.t -> t

Helper to add a minimum level filter

val add_filter : t -> (Log_event.t -> bool) -> t

Add a custom filter function