module Event: sig
.. end
This module defines the concept of event and how to construct them.
type
time
The type of event timestamps.
type
t = private {
|
id :int ; |
|
hostname :string ; |
|
process :int ; |
|
thread :int ; |
|
timestamp :time ; |
|
relative :int ; |
|
level :Level.t ; |
|
logger :Name.t ; |
|
origin :Name.t ; |
|
file :string ; |
|
line :int ; |
|
column :int ; |
|
message :string ; |
|
properties :(string * string) list ; |
|
error :(exn * string) option ; |
}
The type of log events.
val make : Name.t ->
Level.t ->
?origin:Name.t option ->
?file:string ->
?line:int ->
?column:int ->
?properties:(string * string) list -> ?error:exn option -> string -> t
make lg lv ~origin:o ~file:fn ~line:ln ~column:cl ~properties:p ~error:e m
constructs a log event for logger lg
with level lv
, location being
defined by fn
(filename), ln
(line) and cl
(column). p
is an
association list providing user-defined properties, e
is an
optional exception to be recorded (with its backtrace), and o
is
the first logger receiving the event (when None
, the origin is set
to lg
). Identifier, thread, timestamp, relative time, and backtrace
are automatically generated.
val with_logger : Name.t -> t -> t
with_logger l e
returns an event that is identical to e
, except
that its logger is equal to l
.
val bindings : t -> (string * string) list
Returns the bindings for the passed event.
The bindings are an association list to be used for event rendering.
The following keys are defined:
"id"
event identifier;
"hostname"
host name of running program;
"process"
process identifier of running program (a.k.a. pid);
"thread"
thread identifier;
"sec"
seconds of event timestamp;
"min"
minutes of event timestamp;
"hour"
hour of event timestamp;
"mday"
day of month of event timestamp;
"month"
month of year of event timestamp (as a number);
"year"
year of event timestamp (on four digits);
"wday"
day of week of event timestamp (as a string);
"time"
event timestamp (epoch-based);
"relative"
time elapsed between initilization and event creation;
"level"
event level;
"logger"
event logger;
"origin"
first logger that received the event;
"file"
event file (using "<nofile>"
instead of the empty
string);
"filebase"
event file (without directory information);
"line"
event line;
"column"
event column;
"message"
event message;
"properties"
property list of event
(format: "[k1: v1; ...; kn: vn]"
);
"exception"
event exception;
"backtrace"
event exception backtrace.
These keys have precedence over the one given at event creation.
val render_bindings : (string * string) list -> string -> string
render_bindings l fmt
returns a string representing fmt
where all
bindings of the association list l
have been expanded. Bindings,
and their textual format are defined in render
.
val render : string -> t -> string
render fmt e
returns a string representing fmt
where all bindings
of e
have been expanded. Bindings should appear in fmt
is the
$(id:pad)
format where id
is the binding key, and pad the optional
padding. The padding consists of whitespace, on the right if pad
is
positive and on the left otherwise.