NAME

Chroniton::Messages - an event log for Chroniton

SYNOPSIS

  my $log = Chroniton::Messages->new(\*STDERR);

  $log->message("/etc", "starting backup of /etc");
  $log->debug("/etc", "descending into /etc");
  $log->warning("/etc/shadow", "can't read /etc/shadow");
  $log->error("foo", "can't backup foo: doesn't exist");

  $log->add(Chroniton::Event-> ... );

  my @errors  = $log->retrieve("error");
  my @logfile = $log->retrieve_all;

METHODS

new([print])

Creates an instance. Argument print is a reference to a filehandle to write each message to. If none is specified, messages are stored only.

add(message)

Adds a Chroniton::Message object to the log. Dies if the message isn't actually a message (i.e. can't set ID or query type).

retrieve_all

Returns a list of all messages, sorted by their insertion order.

retrieve([type])

Returns a list of all messages of type type, not sorted.

error

warning

message

debug

Adds the respective type of message to the database. Chroniton::Message for the argument ordering, as these methods merely serve as a convenient way to write:

$log->add(Chroniton::Message->type(@_));

summary

Returns a string summarizing the event log.

fatal(message, filename, silent)

Logs an error, saves the logfile, and then dies (via confess), printing the error message to STDERR and all log entries to STDOUT.