Module Message_templates_lwt.Configuration

Lwt configuration builder

Lwt configuration - fluent API for async logger setup

type sink_config = {
  1. sink_fn : Lwt_sink.sink_fn;
  2. min_level : Message_templates.Level.t option;
}

Sink configuration type

type t = {
  1. min_level : Message_templates.Level.t;
  2. sinks : sink_config list;
  3. enrichers : (Message_templates.Log_event.t -> Message_templates.Log_event.t) list;
  4. filters : Message_templates.Filter.t list;
  5. context_properties : (string * Yojson.Safe.t) list;
}

Configuration type

val create : unit -> t

Create a new configuration with default minimum level (Information)

val minimum_level : Message_templates.Level.t -> t -> t

Set minimum level for the logger

val verbose : t -> t

Convenience methods for common levels

val debug : t -> t
val information : t -> t
val warning : t -> t
val error : t -> t
val fatal : t -> t
val write_to_file : ?min_level:Message_templates.Level.t -> ?rolling:Lwt_file_sink.rolling_interval -> ?output_template:string -> string -> t -> t

Add an Lwt file sink with optional minimum level override. Note: The sink is created lazily on first use to avoid Lwt.t in config

val write_to_console : ?min_level:Message_templates.Level.t -> ?colors:bool -> ?stderr_threshold:Message_templates.Level.t -> ?output_template:string -> unit -> t -> t

Add an Lwt console sink with optional minimum level override

val write_to : ?min_level:Message_templates.Level.t -> sink_config -> t -> t

Add a custom Lwt sink function with optional minimum level override. If both the sink_fn has a min_level and one is provided here, the more restrictive (higher) level is used.

Add an enricher function

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

Add a static property enricher

val filter_by : Message_templates.Filter.t -> t -> t

Add a filter

val filter_by_min_level : Message_templates.Level.t -> t -> t

Add minimum level filter

val create_logger : t -> Lwt_logger.t

Create the Lwt logger from configuration