Name
Class::Usul::Log - Create methods for each logging level that encode their output
Synopsis
use Moo;
use Class::Usul::Log;
has '_log' => is => 'ro', isa => LogType,
lazy => TRUE, builder => '_build__log',
reader => 'log', init_arg => 'log';
sub _build__log {
my $self = shift; return Class::Usul::Log->new( builder => $self );
}
# Can now call the following
$self->log->debug( $text );
$self->log->info( $text );
$self->log->warn( $text );
$self->log->error( $text );
$self->log->fatal( $text );
Description
Creates methods for each logging level that encode their output. The logging levels are defined by the log levels constant
Configuration and Environment
Defines the following attributes
- debug
-
Debug flag defaults to FALSE
- 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
- logfile
-
Path to the logfile
Subroutines/Methods
BUILDARGS
Monkey with the constructors signature
BUILD
Creates a set of methods defined by the LOG_LEVELS
constant. The method expects $self->log
and $self->encoding
to be set. It encodes the output string prior calling the log method at the given level
fh
Return the loggers file handle
get_log_attributes
Returns the hash ref passed to the constructor of the log class. Returns undef to indicate no logging, an instance of Class::Null is used instead
Diagnostics
None
Dependencies
- Class::Null
- Class::Usul::Constants
- Class::Usul::Functions
- Moo
- Encode
- File::DataClass::Types
- Log::Handler
Incompatibilities
There are no known incompatibilities in this module
Bugs and Limitations
There are no known bugs in this module. Please report problems to the address below. Patches are welcome
Acknowledgements
Larry Wall - For the Perl programming language
Author
Peter Flanigan, <Support at RoxSoft.co.uk>
License and Copyright
Copyright (c) 2014 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