package easy_logging

  1. Overview
  2. Docs

Attributes

val name : string

Name of the logger:

  • can be displayed in log messages.
  • defines the logger place in the logging tree.
val mutable level : log_level option

Value used to filter log messages.

val mutable handlers : Default_handlers.t list

Registered handlers for this logger.

val parent : logger option

The optional parent of this logger⋅

val propagate : bool

Whether messages to this logger are propagated to its ancestors' handlers.

Classic logging Methods

Each of these methods takes an optional tag list, then a set of parameters the way a printf function does. If the log level of the instance is low enough, a log item will be created theb passed to the handlers.

Example :

logger#warning "Unexpected value: %s" (to_string my_value)
method flash : 'a. ?tags:Default_handlers.tag list -> ('a, unit, string, unit) format4 -> 'a
method error : 'a. ?tags:Default_handlers.tag list -> ('a, unit, string, unit) format4 -> 'a
method warning : 'a. ?tags:Default_handlers.tag list -> ('a, unit, string, unit) format4 -> 'a
method info : 'a. ?tags:Default_handlers.tag list -> ('a, unit, string, unit) format4 -> 'a
method debug : 'a. ?tags:Default_handlers.tag list -> ('a, unit, string, unit) format4 -> 'a

Lazy logging methods

Each of these methods takes a string lazy_t as an input (as well as the optional tag list. If the log level of the instance is low enough, the lazy value will forced into a string, a log item will be created then passed to the handlers.

Example:

logger#ldebug (lazy (heavy_calculation () ))
method ldebug : ?tags:Default_handlers.tag list -> string lazy_t -> unit
method linfo : ?tags:Default_handlers.tag list -> string lazy_t -> unit
method lwarning : ?tags:Default_handlers.tag list -> string lazy_t -> unit
method lerror : ?tags:Default_handlers.tag list -> string lazy_t -> unit
method lflash : ?tags:Default_handlers.tag list -> string lazy_t -> unit

String logging methods

These methods take a simple string as input.

method sdebug : ?tags:Default_handlers.tag list -> string -> unit
method serror : ?tags:Default_handlers.tag list -> string -> unit
method sflash : ?tags:Default_handlers.tag list -> string -> unit
method sinfo : ?tags:Default_handlers.tag list -> string -> unit
method swarning : ?tags:Default_handlers.tag list -> string -> unit

Other methods

method set_level : log_level -> unit

Sets the log level of the logger instance.

method add_handler : Default_handlers.t -> unit

Adds a handler to the logger instance.

method get_handlers : Default_handlers.t list
method effective_level : log_level

Returs this logger level if it is not None, else searches amongst ancestors for the first defined level; returns NoLevel if no level can be found.

method set_propagate : bool -> unit
OCaml

Innovation. Community. Security.