LogLite(3pm) | User Contributed Perl Documentation | LogLite(3pm) |
Log::LogLite - The "Log::LogLite" class helps us create simple logs for our application.
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);
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 controlled by changing the template, and by defining a default message. The class uses the IO::LockedFile class.
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.
'[<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.
Rani Pinchuk, rani@cpan.org
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.
2022-12-04 | perl v5.36.0 |