Legend:
Library
Module
Module type
Parameter
Class
Class type
Logging functions
This module provides logging functions. It is actually a thin extension of Lwt_log_core, adding logging destinations that are only available on Unix and Windows (such as files, standard output, and the system log). Being a thin extension, most of the functions in this module are actually the ones in Lwt_log_core. They are not repeated on this page, however, so please read both Lwt_log_coreand this page for a complete understanding.
Each logging message has a section. Sections can be used to structure your logs. For example you can choose different loggers according to the section.
Each section carries a level, and messages with a lower log level than than the section level will be dropped.
Section levels are initialised using the contents of the LWT_LOG environment variable, which must contain one or more rules of the form pattern -> level separated by ";". Where pattern is a string that may contain *.
For example, if LWT_LOG contains:
access -> warning;
foo[*] -> error
then the level of the section "access" is Warning and the level of any section matching "foo[*]" is Error.
If the pattern is omited in a rule then the pattern "*" is used instead, so LWT_LOG may just contain "debug" for instance.
By default, the following rule apply : "* -> notice"
val load_rules : ?fail_on_error:bool ->string -> unit
Reset the rules set when parsing the LWT_LOG environment variable using this string.
parameterfail_on_error
defines if the function will raise Failure if it encounters a malformed rule
raisesFailure
if an invalid rule is found and fail_on_error is true
load_rules parses the rules string and validates the rules before loading them. If fail_on_error is true, invalid rules will cause this function to raise Failure and leave existing rules unchanged. If fail_on_error is false (this is the default), it tries to load as many rules as possible and ignore invalid ones. If the rules string itself cannot be parsed, existing rules are always left unchanged.
add_rule pattern level adds a rule for sections logging levels. The rule is added before all other rules. It takes effect immediately and affects all sections for which the level has not been set explicitly with Section.set_level. pattern may contains *. For example:
append_rule pattern level adds the given rule after all other rules. For example to set the default fallback rule:
Lwt_log_core.append_rule "*" Lwt_log_core.Info
val reset_rules : unit -> unit
removes all rules.
Logging functions
val log :
?exn:exn ->?section:section->?location:(string * int * int)->?logger:logger->level:level->string ->unit Lwt.t
log ?section ?logger ~level message logs a message.
section defaults to Section.main. If logger is not specified, then the default one is used instead (see default).
If exn is provided, then its string representation (= Printexc.to_string exn) will be append to the message, and if possible the backtrace will also be logged.
location contains the location of the logging directive, it is of the form (file_name, line, column).
val ign_log_f :
?exn:exn ->?section:section->?location:(string * int * int)->?logger:logger->level:level->('a, unit, string, unit)Pervasives.format4->'a
The default logger. It is used as default when no one is specified. If Lwt_core is linked (in the package lwt.unix) the default logger sends all messages to standard error. Otherwise the default logger is null.