NAME

Util::Medley::Logger - Yet another class for logging.

VERSION

version 0.012

SYNOPSIS

 my $log = Util::Medley::Logger->new;
 
 $log->fatal($msg);   
 $log->error($msg);
 $log->warn($msg);
 $log->info($msg);
 $log->verbose(Smsg);
 $log->debug($msg);

 $log->deprecated("old()", "new()");
 

DESCRIPTION

A simple logging class. By default all logs are written to stderr.

ATTRIBUTES

disableStderr

If provided and true, will disable logging messages to stderr. You should use the 'filename' attribute if you provide true.

type: Bool
default: 0

filename

If provided, indicates where to write log messages. This will not disable stderr. To do that use disableStderr().

Note that file locking is used when writing to a file. This allows you to have multiple processes writing to the same log file without stomping on each other.

type: Str
default: undef

logDetailLevel (<int>)

Used to indicate how much detail to output with each message. Here is a breakdown:

1 - <msg>
2 - [level] <msg>
3 - [level] [date] <msg>
4 - [level] [date] [pid] <msg>
5 - [level] [date] [pid] [caller($frames)] <msg>
type: Bool
default: 3
env var: MEDLEY_LOG_DETAIL_LEVEL

logDetailLevelDebug

Get or set the logDetailLevelDebug value. This overrides the logDetailLevel.

type: Int
default: undef
env var: MEDLEY_LOG_DETAIL_LEVEL_DEBUG

logDetailLevelVerbose

Get or set the logDetailLevelVerbose value. This overrides the logDetailLevel.

type: Int
default: undef
env var: MEDLEY_LOG_DETAIL_LEVEL_VERBOSE

logDetailLevelInfo

Get or set the logDetailLevelInfo value. This overrides the logDetailLevel.

type: Int
default: undef
env var: MEDLEY_LOG_DETAIL_LEVEL_INFO

logDetailLevelWarn

Get or set the logDetailLevelWarn value. This overrides the logDetailLevel.

type: Int
default: undef
env var: MEDLEY_LOG_DETAIL_LEVEL_WARN

logDetailLevelError

Get or set the logDetailLevelError value. This overrides the logDetailLevel.

type: Int
default: undef
env var: MEDLEY_LOG_DETAIL_LEVEL_ERROR

logDetailLevelFatal

Get or set the logDetailLevelFatal value. This overrides the logDetailLevel.

type: Int
default: undef
env var: MEDLEY_LOG_DETAIL_LEVEL_FATAL

logDetailLevelDeprecated

Get or set the logDetailLevelDeprecated value. This overrides the logDetailLevel.

type: Int
default: undef
env var: MEDLEY_LOG_DETAIL_LEVEL_DEPRECATED

logFrames

Used to indicate how many frames to go back when logDetailLevel invokes the caller() function. In most cases you shouldn't have to bother with this.

type: Int
default: 2
env var: MEDLEY_LOG_FRAMES

logLevel

Indicates what level of log detail you want.

Levels (in order of severity):

- debug
- verbose
- info
- warn
- error
- fatal
type: Str
default: info
env var: MEDLEY_LOG_LEVEL

utf8

Flag to toggle utf8 mode.

type: Bool
default: 0

METHODS

debug

Writes a debug message to the log.

usage:
$util->debug($msg);

$util->debug(msg => $msg);
args:
msg [Str]

The message to log.

deprecated

Writes a deprecated message to the log. First arg is the original method/sub. Second arg is the new method/sub.

usage:
$util->deprecated($orig, $new);

$util->deprecated(orig => $orig, new => $new);
args:
orig [Str]

Name of the deprecated method.

new [Str]

Name of the new method.

error

Writes an error message to the log.

usage:
$util->error($msg);

$util->error(msg => $msg);
args:
msg [Str]

The message to log.

fatal

Writes a fatal message to the log and exits with 1.

usage:
$util->fatal($msg);

$util->fatal(msg => $msg);
args:
msg [Str]

The message to log.

getLogLevels

Returns an array of all possible levels in severity order.

usage:
@levels = $util->getLogLevels;

info

Writes an info message to the log.

usage:
$util->info($msg);

$util->info(msg => $msg);
args:
msg [Str]

The message to log.

verbose

Writes a verbose message to the log.

usage:
$util->verbose($msg);

$util->verbose(msg => $msg);
args:
msg [Str]

The message to log.

warn

Writes a warn message to the log.

usage:
$util->warn($msg);

$util->warn(msg => $msg);
args:
msg [Str]

The message to log.