NAME
XLog::Formatter::Pattern - XLog pattern formatter backend
SYNPOSIS
XLog::set_formatter(XLog::Formatter::Pattern->new("%1t %c[%L/%1M]%C %f:%l,%F(): %m"));
XLog::warning("hi");
DESCRIPTION
Default formatter for XLog. Uses strftime
-like string syntax to format log messages. Format string is a string with a number of special tokens which will be replaced with additional information.
Some tokens supports up to 2 modifiers x
and y
in one of the following formats (given that T
is a token): %T or %xT or %x.yT or %.yT
If any of x
or y
are absent, it is considered 0 (for example %t
is the same as %0t
and %0.0t
). If a token supports modifiers it will be noted below what x
and y
means.
- %L
-
Level string ("debug", "info", ...)
- %M
-
Module name
- %F
-
Function name
- %f
-
Filename.
x=0: only filename
x=1: full path as it appeared during loading module (perl) or compilation (C)
- %l
-
Line number
- %m
-
Log message
- %t
-
Current time.
Modifier
x
chooses time format,y
chooses microseconds precisionx=0: YYYY/MM/DD HH:MM:SS
x=1: YY/MM/DD HH:MM:SS
x=2: HH:MM:SS
x=3: UNIX TIMESTAMP
y>0: high resolution time, adds fractional part after seconds with "y" digits precision
Examples:
%t: 2020/01/31 23:59:59 %2t: 23:59:59 %2.3t: 23:59:59.345
- %T
-
Current thread id. Usually makes sense only for C code or threaded perls.
- %p
-
Current process id.
- %P
-
Current process title
- %c
-
Start colored text. Inserts special control characters and all text after this token will be colored according to log level. Only for unix consoles.
- %C
-
End colored text
METHODS
new($format)
Create pattern formatter object