package easy_logging

  1. Overview
  2. Docs
Module to log messages. Aimed at being both powerful and easy to use

Install

dune-project
 Dependency

Authors

Maintainers

Sources

v0.6.2.tar.gz
md5=2c805f25050b6917a4c99edbd3bb73fb
sha512=a20aa4cbcbfa4b8241daf4775f86e91ed3b91dcec51ad628edff5d6857354e63d93c312c023a5c0e59f2924f051d618636701563933e89762af63679f981f18b

doc/easy_logging/Easy_logging/Handlers/index.html

Module Easy_logging.Handlers

Default implementation of a Handlers module.

This is the Handlers module. It provides simple yet adaptable handlers implementation.

type log_formatter = Easy_logging__.Logging_types.log_item -> string

Type definitions

type filter = Easy_logging__.Logging_types.log_item -> bool
type t = {
  1. mutable fmt : log_formatter;
  2. mutable level : Easy_logging__.Logging_types.level;
  3. mutable filters : filter list;
  4. output : string -> unit;
}

Type of a handler

A handler is made of:

  • a formatter that transforms a log item into a string.
  • a level used to filter out items.
  • an array of possible additional custom filters.
  • an output function, that takes a string and does the output job.

Handlers creation helpers

module CliHandler : sig ... end

Module to create handlers that output to stdout or stderr.

module FileHandler : sig ... end

Module to create handlers that output to a file.

type config = {
  1. file_handlers : FileHandler.config;
}
val default_config : config
type desc =
  1. | Cli of Easy_logging__.Logging_types.level
  2. | CliErr of Easy_logging__.Logging_types.level
  3. | File of string * Easy_logging__.Logging_types.level
  4. | RotatingFile of string * Easy_logging__.Logging_types.level * int * int
val make : ?config:config -> desc -> t

Used for quick handler creation, e.g.

  • Cli handler: outputs colored messages to stdout

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

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

Handlers setup

val set_level : t -> Easy_logging__.Logging_types.level -> unit

Sets the level of a handler.

val set_formatter : t -> log_formatter -> unit

Sets the formatter of a handler.

val add_filter : t -> filter -> unit

Adds a filter to a handler.

val apply : t -> Easy_logging__.Logging_types.log_item -> unit

Auxiliary function.