Class::Usul::Log - Create methods for each logging level that encode their output
use Class::Usul::Log; use File::DataClass::IO; my $file = io [ 't', 'test.log' ]; my $log = Class::Usul::Log->new( encoding => 'UTF-8', logfile => $file ); my $text = 'Your error message goes here'; # Can now call the following. The text will be encoded UTF-8 $log->debug( $text ); # Does not log as debug was not true in the constructor $log->info ( $text ); $log->warn ( $text ); $log->error( $text ); $log->alert( $text ); $log->fatal( $text );
Creates methods for each logging level that encode their output. The logging levels are defined by the log levels constant
Defines the following attributes
debug
Debug flag defaults to false. If set to true calls to log at the debug level will succeed rather than being ignored
encoding
Optional output encoding. If present output to the logfile is encoded
log
Optional log object. Will instantiate an instance of Log::Handler if this is not provided
log_attributes
Attributes used to create the log object
log_class
The classname of the log object. This is loaded on demand
logfile
Path to the logfile
BUILDARGS
Monkey with the constructors signature
filehandle
Return the loggers file handle. This was added for IO::Async, so that we can tell it not to close the log file handle when it forks a child process
get_log_attributes
Returns the hash reference passed to the constructor of the log class. Returns undef to indicate no logging, an instance of Class::Null is used instead
undef
$self->log( { level => $level, message => $message } );
Logs the message at the given level
None
There are no known incompatibilities in this module
There are no known bugs in this module. Please report problems to the address below. Patches are welcome
Larry Wall - For the Perl programming language
Peter Flanigan, <pjfl@cpan.org>
<pjfl@cpan.org>
Copyright (c) 2015 Peter Flanigan. All rights reserved
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic
This program is distributed in the hope that it will be useful, but WITHOUT WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
To install Class::Usul, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Class::Usul
CPAN shell
perl -MCPAN -e shell install Class::Usul
For more information on module installation, please visit the detailed CPAN module installation guide.