NAME

EntityModel::Log - simple logging support for EntityModel

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.

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.

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

  • 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.

AUTHOR

Tom Molesworth <cpan@entitymodel.com>

LICENSE

Copyright Tom Molesworth 2008-2011. Licensed under the same terms as Perl itself.