Logger::Simple - Implementation of the Simran-Log-Log and Simran-Error-Error modules
Contents
Acknowledgements
This module is based on the Simran::Log::Log and Simran::Error::Error modules. I liked the principle
behind them, but felt that the interface could be a bit better.
My thanks also goes out once again to Damian Conway for Object Oriented Perl, and also to Sam Tregar, for
his book "Writing Perl Modules for CPAN". Both were invaluable references for me.
I would also like to thank Jerry Heden for his Object::InsideOut module, which I used to create this
module.
Copyright
Description
new "my $log=Logger::Simple->new(LOG=>"/tmp/logfile");"
The new method creates the Logger::Simple object as an inside-out object. The Log parameter is a
mandatory one that must be passed to the object at creation, or the object will fail. Upon
creation, this method will also call the open_log method which opens the log file.
write
"$log->write("This is an error message");"
This method will write a message to the logfile, and will update the internal HISTORY array.
retrieve_history
"my @history = $log->retrieve_history;" "my $msg = $log->retrieve_history;"
When called in scalar context, it will return the last message written to the HISTORY array. When
called in a list context, it will return the entire HISTORY array
clear_history
"$log->clear_history;"
This method will clear the internal HISTORY array
Export
None by default.
Name
Logger::Simple - Implementation of the Simran-Log-Log and Simran-Error-Error modules
See Also
perl(1). Object::InsideOut Simran::Log::Log Simran::Error::Error perl v5.30.0 2020-01-28 Simple(3pm)
Synopsis
use Logger::Simple;
my $log=Logger::Simple->new(LOG=>"/tmp/program.log");
my $x=5;my $y=4;
if($x>$y){
$log->write("\$x is greater than \$y");
}
