NAME

Logger::Simple - Implementation of the Simran-Log-Log and Simran-Error-Error modules

SYNOPSIS

use Logger::Simple;
my $log=Logger::Simple->new({LOG=>"/tmp/program.log",CARP=>'1'});
my $x=5;my $y=4;
if($x>$y){
  # Set an error message
  $log->set("\$x is greater than \$y");

  # Write a message to the log file 
  $log->write("\$x is greater than \$y");
}
$log->set("Another error message");

# Get entire Error Message History
my @msgs = $log->message;
foreach my $m(@msgs){
  print "Message: $m\n";
}

# Get the last set error message
my $message=$log->message;
print "Message: $message\n";

DESCRIPTION

new

new(LOG=>"/tmp/logfile",CARP=>'1');

This creates the Logger::Simple object, and initializes it with two parameters. The LOG parameter is the name of the file to which the object will write the log. The CARP parameter will provide more error reporting within the object. Upon creation of the object, it will also make a call to the open method, which opens the file using the FileHandle object that is stored within the FILEHANDLE parameter.

set

set("This is an error message");

This method takes an argument of a string and saves it within two parameters of the object. It saves it in the ERROR parameter, which is the last error message that is set, and it saves it to the HISTORY parameter, which is an array that contains all set error messages.

write

write("This is a log message");

This method takes an argument of a string and writes it to the open logfile that was opened upon creation of the Logger::Simple object.

message

@array = $object->message;

or

$msg = $object->message;

When this method is called in a list context, it will return the HISTORY parameter within the object, which is an anonymous array. When called in a scalar context, it returns the last error message that was set, which is in the ERROR parameter of the object.

EXPORT

None by default.

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.

AUTHOR

Thomas Stanley

Thomas_J_Stanley@msn.com

I can also be found on http://www.perlmonks.org as TStanley. You can also direct any questions concerning this module there as well.

COPYRIGHT

Copyright (C) 2002 Thomas Stanley. All rights reserved. This program is free software; you can distribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

perl(1).