Module Message_templates_lwt.Lwt_file_sink

Lwt file sink with rolling support

Lwt file sink - async file output with rolling support

type rolling_interval =
  1. | Infinite
  2. | Daily
  3. | Hourly

Rolling interval type

type t = {
  1. base_path : string;
  2. mutable current_path : string;
  3. mutable fd : Lwt_unix.file_descr;
  4. output_template : string;
  5. rolling : rolling_interval;
  6. mutable last_roll_time : Ptime.t;
  7. mutex : Lwt_mutex.t;
}

Internal state for Lwt file sink

val default_template : string

Default output template

val now : unit -> Ptime.t

Get current time

val format_timestamp : Ptime.t -> string

Format timestamp for display

val format_date : Ptime.t -> string

Get date string for file naming

val format_hour : Ptime.t -> string

Get hour string for file naming

val generate_path : string -> rolling_interval -> string

Generate file path based on rolling interval

val should_roll : t -> Ptime.t -> bool

Check if we need to roll over

val roll : t -> unit Lwt.t

Roll to a new file

val format_output : t -> Message_templates.Log_event.t -> string

Format output string

val emit : t -> Message_templates.Log_event.t -> unit Lwt.t

Emit a log event

val flush : t -> unit Lwt.t

Flush output

val close : t -> unit Lwt.t

Close the sink

val create : ?output_template:string -> ?rolling:rolling_interval -> string -> t Lwt.t

Create a new Lwt file sink