NAME
XLog::Formatter - Base class for pure-perl formatter backends
SYNPOSIS
package MyFormatter;
use parent 'XLog::Formatter';
sub new {
my ($class, ...) = @_;
my $self = $class->SUPER::new();
...
return $self;
}
sub format {
my ($self, $msg, $level, $module_name, $file, $line, $func) = @_;
return "[".time()."] $msg at $file:$line";
}
DESCRIPTION
This is a base class for making pure-perl formatter object. API is very simple - you need to override a single subroutine format and return formatted string.
METHODS
new()
Create backend object.
Keep in mind that if you override new method you MUST create object by calling SUPER, not blessing new object by yourself, because there will be a C++ proxy object attached to perl object.
format($msg, $level, $module_name, $file, $line, $func)
You must override this method and return resulting formatted log message.
The parameters are:
- $msg
-
Log message as it was passed by user
- $level
-
Log level (one of the constants)
- $module_name
-
Log module name
- $file
-
Filename with path where loging code is written
- $line
-
Line in file where loging code is written
- $func
-
Function or subroutine name where loging code is written
2 POD Errors
The following errors were encountered while parsing the POD:
- Around line 47:
=over without closing =back
- Around line 73:
=over is the last thing in the document?!