A library for general logging.
Although this module is fully Async-safe it exposes almost no Deferreds. This is partially a design choice to minimize the impact of logging in code, and partially the result of organic design (i.e. older versions of this interface did the same thing).
A (limited) Blocking
module is supplied to accommodate the portion of a program that
runs outside of Async.
Describes both the level of a log and the level of a message sent to a log. There is an ordering to levels (`Debug < `Info < `Error), and a log set to a level will never display messages at a lower log level.
description of boundaries for file rotation.
If all fields are None
the file will never be rotated. Any field set to Some
will cause rotation to happen when that boundary is crossed. Multiple boundaries
may be set. Log rotation always causes incrementing rotation conditions (e.g. size)
to reset.
The condition keep
is special and does not follow the rules above. When a log is
rotated keep
is examined and logs that do not fall under its instructions are
deleted. This deletion takes place on rotation only, and so may not happen. The
meaning of keep options are:
`All
-- never delete`Newer_than span
--
delete files with a timestamp older than Time.sub (Time.now ()) span
. This
normally means keeping files that contain at least one message logged within
span. If span is short enough this option can delete a just rotated file.`At_least i
-- keep the i most recent filesLog rotation does not support symlinks, and you're encouraged to avoid them in production applications. Issues with symlinks:
Sane log rotation defaults.
Writes dated log files. Files are rotated every time the day changes in the given zone (uses the machine's zone by default). If the dated log file already exists, it's appended to.
Logs are never deleted. Best practice is to have an external mechanism archive old logs for long term storage.
create f
returns a t, given a function that actually performs the final output
work. It is the responsibility of the write function to contain all state, and to
clean up after itself when it is garbage collected (which may require a finalizer).
The "stock" output modules support a sexp and bin_prot output format, and other output modules should make efforts to support them as well where it is meaningful/appropriate to do so.
The unit Deferred returned by the function should not be fulfilled until the all of the messages in the given queue are completely handled (e.g. written to disk).
Async programs often have a non-Async portion that runs before the scheduler begins to capture command line options, do setup, read configs, etc. This module provides limited global logging functions to be used during that period. Calling these functions after the scheduler has started will raise an exception. They otherwise behave similarly to the logging functions in the Async world.
raw
printf like logging for raw (no level) messages. Raw messages are still
output with a timestamp.
info
printf like logging at the `Info log level
error
printf like logging at the `Info log level
error
printf like logging at the `Info log level
An interface for singleton logs
logging functions as the functions that operate on a given log. In this case they operate on a single log global to the module
This functor can be called to generate "singleton" logging modules
Programs that want simplistic single-channel logging can open this module. It provides a global logging facility to a single output type at a single level. More nuanced logging can be had by using the functions that operate on a distinct Log.t type.
flushed
returns a Deferred.t that is fulfilled when the last message delivered to t
before the call to flushed is out the door.
raw
printf like logging for raw (no level) messages. Raw messages are still
output with a timestamp.
debug
printf like logging at the `Debug log level
info
printf like logging at the `Info log level
error
printf like logging at the `Error log level
printf
generalized printf style logging