NAME
EntityModel::Log - simple logging support for EntityModel
VERSION
version 0.003
SYNOPSIS
use EntityModel::Log ':all';
logDebug("Test something");
logInfo("Object [%s] found", $obj->name);
logError("Fatal problem");
logInfo(sub { my $str = heavy_operation(); return 'Failed: %s', $str });
DESCRIPTION
Yet another logging class. Provides a procedural and OO interface as usual - intended for use with EntityModel only, if you're looking for a general logging framework try one of the other options in the "SEE ALSO" section.
PROCEDURAL METHODS
logDebug
Raise a debug message, but only if the debug flag is set. Expect a high volume of these during normal operation so live server has this switched off.
logInfo
Raise an informational message, which we'd like to track for stats reasons - indicates normal operations rather than an error condition.
logWarning
Raise a warning message, for things like 'article does not exist', expect a few of these in regular operations but they aren't serious enough to be potential bugs or system problems.
logError
Raise an error - this is likely to be a genuine system problem.
logStack
Raise an error with stack - this is likely to be a genuine system problem.
stackTrace
Get a stack trace, as an array of hashref entries, skipping the top two levels.
OO METHODS
new
Constructor - currently doesn't do much.
path
Accessor for path setting, if given a new path will close existing file and direct all new output to the given path.
handle
Direct accessor for the file handle.
pid
Current PID, used for fork tracking.
isOpen
Returns true if our log file is already open.
disabled
Returns true if we're running disabled.
close
Close the log file if it's currently open.
close_after_fork
Close any active handle if we've forked. This method just does the closing, not the check for $$.
open
Open the logfile.
reopen
Helper method to close and reopen logfile.
parseMessage
Generate appropriate text based on whatever we get passed.
Each item in the parameter list is parsed first, then the resulting items are passed through sprintf. If only a single item is in the list then the resulting string is returned directly.
Item parsing handles the following types:
Single string is passed through unchanged
Any coderef is expanded in place (recursively - a coderef can return other coderefs)
Arrayref or hashref is expanded via Data::Dump
Other references are stringified
Undef items are replaced with the text 'undef'
raise
Raise a log message
$level - numeric log level
@data - message data
debug
Log a message at debug level.
SEE ALSO
Log::Log4perl or just search for "log" on search.cpan.org, plenty of other options.
AUTHOR
Tom Molesworth <cpan@entitymodel.com>
LICENSE
Copyright Tom Molesworth 2008-2011. Licensed under the same terms as Perl itself.