NAME

SystemLogger Class for writing to syslog.

SYNOPSIS

use SystemLogger;

# instantiate
my $sl=SystemLogger->new(ident=>"MyProcessName",priority=>"DEBUG");

# attempt to open syslog
if (!$sl->open()) { die "Unable to open syslog: ".$sl->error(); }

# log to syslog
$sl->log("I have a bad feeling about this.","WARNING");

# close syslog (if open)
$sl->close();

DESCRRIPTION

Class for handling writing to syslog in an easy manner.

CONSTRUCTOR

new()

Instantiates the SystemLogger-class.

Accepts the following parameters:

Returns a SystemLogger instance.

METHODS

open()

Open syslog for use.

No input parameters accepted.

Attempts to open syslog for use.

Returns 1 upon success, 0 upon failure. Please check the error()- method to find out more about a potential failure.

log()

Writes a log entry to syslog.

Accepted input is in the following order: message, priority.

Message is the message to write to syslog. SCALAR. Required.

Priority is the message priority. SCALAR. Optional. Defaults to "INFO". Valid levels are: DEBUG, INFO, WARNING, ERR and CRIT.

Only messages that are at the priority-level set in the constructor or higher will be written to syslog. Other messages are just dropped and method still returning success.

Returns 1 upon success, 0 upon failure. Please check the error()-method for more information upon failure.

prio2Int()

Converts a textual priority to int.

Accepted input is "priority". SCALAR. Optional. Defaults to "ERR".

Valid priority input: DEBUG, INFO, WARNING, ERR and CRIT.

Returns the int for the specified priority, or 1 if not recognized (=INFO).

int2Prio()

Convert int to textual priority.

Accepted input is priority int. SCALAR. Optional. Defaults to 1 (INFO).

Valid priority input: 0 (DEBUG), 1 (INFO), 2 (WARNING), 3 (ERR), 4 (CRIT).

Returns the textual priority or "INFO" if not specified or recognized.

close()

Closes the syslog.

No input accepted.

No return value set.

isOpen()

Return if syslog has been opened or not?

No input accepted.

Returns 1 for open, 0 for not open.

error()

Returns last error from the instance.

No input accepted.

Returns the last error or blank if none.