LogLite(3) User Contributed Perl Documentation LogLite(3)NAMELog::LogLite - The "Log::LogLite" class helps us create simple logs for
our application.
SYNOPSIS
use Log::LogLite;
my $LOG_DIRECTORY = "/where/ever/our/log/file/should/be";
my $ERROR_LOG_LEVEL = 6;
# create new Log::LogLite object
my $log = new Log::LogLite($LOG_DIRECTORY."/error.log", $ERROR_LOG_LEVEL);
...
# we had an error
$log->write("Could not open the file ".$file_name.": $!", 4);
DESCRIPTION
In order to have a log we have first to create a "Log::LogLite" object.
The c<Log::LogLite> object is created with a logging level. The default
logging level is 5. After the "Log::LogLite" object is created, each
call to the "write" method may write a new line in the log file. If the
level of the message is lower or equal to the logging level, the
message will be written to the log file. The format of the logging
messages can be controled by changing the template, and by defining a
default message. The class uses the IO::LockedFile class.
CONSTRUCTOR
new ( FILEPATH [,LEVEL [,DEFAULT_MESSAGE ]] )
The constructor. FILEPATH is the path of the log file. LEVEL is the
defined logging level - the LEVEL data member. DEFAULT_MESSAGE will
define the DEFAULT_MESSAGE data member - a message that will be
added to the message of each entry in the log (according to the
TEMPLATE data member, see below).
The levels can be any levels that the user chooses to use. There
are, though, recommended levels:
0 the application is unusable
1 the application is going to be unusable
2 critical conditions
3 error conditions
4 warning conditions
5 normal but significant condition
6 informational
7+ debug-level messages
The default value of LEVEL is 5. The default value of
DEFAULT_MESSAGE is "". Returns the new object.
METHODS
write( MESSAGE [, LEVEL ] )
If LEVEL is less or equal to the LEVEL data member, or if LEVEL is
undefined, the string in MESSAGE will be written to the log file.
Does not return anything.
level( [ LEVEL ] )
Access method to the LEVEL data member. If LEVEL is defined, the
LEVEL data member will get its value. Returns the value of the
LEVEL data member.
default_message( [ MESSAGE ] )
Access method to the DEFAULT_MESSAGE data member. If MESSAGE is
defined, the DEFAULT_MESSAGE data member will get its value.
Returns the value of the DEFAULT_MESSAGE data member.
log_line_numbers( [ BOOLEAN ] )
If this flag is set to true, the <called_by> string will hold the
file that calls the subroutine and the line where the call is
issued. The default value is zero.
template( [ TEMPLATE ] )
Access method to the TEMPLATE data member. The TEMPLATE data member
is a string that defines how the log entries will look like. The
default TEMPLATE is:
'[<date>] <<level>> <called_by><default_message><message>'
Where:
<date> will be replaced by a string that represent
the date. For example: 09/01/2000 17:00:13
<level> will be replaced by the level of the entry.
<called_by> will be replaced by a call trace string. For
example:
CGIDaemon::listen > MyCGIDaemon::accepted
<default_message> will be replaced by the value of the
DEFAULT_MESSAGE data member.
<message> will be replaced by the message string that
is sent to the C<write> method.
Returns the value of the TEMPLATE data member.
AUTHOR
Rani Pinchuk, rani@cpan.org
COPYRIGHT
Copyright (c) 2001-2002 Ockham Technology N.V. & Rani Pinchuk. All
rights reserved. This package is free software; you can redistribute
it and/or modify it under the same terms as Perl itself.
SEE ALSOIO::LockedFile(3)POD ERRORS
Hey! The above document had some coding errors, which are explained
below:
Around line 282:
You forgot a '=back' before '=head1'
perl v5.14.1 2002-09-24 LogLite(3)