package easy_logging

  1. Overview
  2. Docs

Module Easy_logging.Default_handlersSource

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

Sourcetype tag = unit

we don't use tags here

Sourcetype log_item = {
  1. level : Easy_logging__.Easy_logging_types.level;
  2. logger_name : string;
  3. msg : string;
  4. tags : tag list;
}
Sourcetype log_formatter = log_item -> string
Sourcetype 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

Sourceval format_default : log_item -> string
Sourceval format_color : log_item -> string

Handlers creation and setup utility functions

Sourceval make_cli_handler : Easy_logging__.Easy_logging_types.level -> t
Sourcetype file_handlers_config = {
  1. logs_folder : string;
  2. truncate : bool;
  3. file_perms : int;
}
Sourceval file_handlers_defaults : file_handlers_config
Sourcetype config = {
  1. mutable file_handlers : file_handlers_config;
}
Sourceval config : config
Sourceval set_config : config -> unit
Sourceval make_file_handler : Easy_logging__.Easy_logging_types.level -> string -> t
Sourcetype desc =
  1. | Cli of Easy_logging__.Easy_logging_types.level
  2. | File of string * Easy_logging__.Easy_logging_types.level
Sourceval make : desc -> t

Handlers usage

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

Innovation. Community. Security.