XLog::Formatter - Base class for pure-perl formatter backends
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"; }
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.
format
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.
new
SUPER
You must override this method and return resulting formatted log message.
The parameters are:
Log message as it was passed by user
Log level (one of the constants)
Log module name
Filename with path where loging code is written
Line in file where loging code is written
Function or subroutine name where loging code is written
2 POD Errors
The following errors were encountered while parsing the POD:
=over without closing =back
=over is the last thing in the document?!
To install XLog, copy and paste the appropriate command in to your terminal.
cpanm
cpanm XLog
CPAN shell
perl -MCPAN -e shell install XLog
For more information on module installation, please visit the detailed CPAN module installation guide.