13 Jul 2021 11:04:13 UTC
- Distribution: XLog
- Source (raw)
- Browse (raw)
- How to Contribute
- Testers (39 / 0 / 3)
- KwaliteeBus factor: 1
- License: unknown
- Activity24 month
- Download (22.6KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version
XLog::Formatter::Pattern - XLog pattern formatter backend
XLog::set_formatter(XLog::Formatter::Pattern->new("%1t %c[%L/%1M]%C %f:%l,%F(): %m")); XLog::warning("hi");
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
yin one of the following formats (given that
Tis a token): %T or %xT or %x.yT or %.yT
If any of
yare absent, it is considered 0 (for example
%tis the same as
%0.0t). If a token supports modifiers it will be noted below what
Level string ("debug", "info", ...)
x=0: only filename
x=1: full path as it appeared during loading module (perl) or compilation (C)
x=0: normal behaviour
x=1: multiline message support. Each line of message will be "log-formatted" as if they all were written in log separately.
xchooses time format,
ychooses microseconds precision
x=0: YYYY-MM-DD HH:MM:SS
x=1: YY-MM-DD HH:MM:SS
x=3: YYYY/MM/DD HH:MM:SS
x=4: UNIX TIMESTAMP
y>0: high resolution time, adds fractional part after seconds with "y" digits precision
%t: 2020-01-31 23:59:59 %2t: 23:59:59 %2.3t: 23:59:59.345
Current thread id. Usually makes sense only for C code or threaded perls.
Current process id.
Current process title. There is a trick, as for Perl interpreter it will always be
perl, which makes it senseless. Instead, it spies on
$0and uses that value (transformed via decorator, see below) as process name.
Start colored text. Inserts special control characters and all text after this token will be colored according to log level. Only for unix consoles.
End colored text
Create pattern formatter object
Sets the callback, which will be invoked as
to get process name for
%Pin pattern above.
The callback is invoked only upon
If no decorator has been set, the default one is applied. It will cut script path in
$0, leaving only script basename, i.e.
$0will be set to
path/to/my_script.plby default. The default decorator will cut it to: