package easy_logging

  1. Overview
  2. Docs

Default implementation of a Handlers module.

In the DefaultHandlers module, handlers have level of their own. Their are two kinds of logger :

  • Cli handler: outputs colored messages to stdout

    let h = Default_handlers.make (Cli Debug) 
  • File handler : outputs messages to a given file

    let h = Default_handlers.make (File ("filename", Debug)) 

Type definitions

type tag = unit

we don't use tags here

type log_item = {
  1. level : Easy_logging__.Easy_logging_types.level;
  2. logger_name : string;
  3. msg : string;
  4. tags : tag list;
}
type log_formatter = log_item -> string
type t = {
  1. mutable fmt : log_formatter;
  2. mutable level : Easy_logging__.Easy_logging_types.level;
  3. output : out_channel;
}

type of a handler

Formatting functions

val format_default : log_item -> string
val format_color : log_item -> string

Handlers creation and setup utility functions

val make_cli_handler : Easy_logging__.Easy_logging_types.level -> t
type file_handler_defaults_t = {
  1. logs_folder : string;
  2. truncate : bool;
  3. file_perms : int;
}
val file_handler_defaults : file_handler_defaults_t ref
val set_file_handler_defaults : file_handler_defaults_t -> unit
val make_file_handler : Easy_logging__.Easy_logging_types.level -> string -> t
type desc
val make : desc -> t

Handlers usage

val set_level : t -> Easy_logging__.Easy_logging_types.level -> unit
val set_formatter : t -> log_formatter -> unit
val apply : t -> log_item -> unit
OCaml

Innovation. Community. Security.