Tema Novikov

NAME

Crane::Logger - Log manager

SYNOPSIS

  use Crane::Logger;
  
  log_fatal('Fatal message', caller);
  log_error('Error message');
  log_warning('Warning message', $ref);
  log_info("First line\nSecond line\n");
  log_debug($ref);
  log_verbose('First line', 'Second line');

DESCRIPTION

Simple log manager with six log levels. Supports auto split messages by "end of line" and dump references using Data::Dumper.

Log entry

Each log entry looks like ...

  [2013-12-30 02:36:22 +0400 1388356582] Hello, world!

... and contains:

Date

Date in ISO format: YYYY-MM-DD.

  2013-12-30
Time

Time in ISO format: hh:mm:ss.

  02:36:22
Time zone

Time zone in ISO format: ±hhmm.

  +0400
Unix time

Unix time.

  1388356582
Message

Log message.

  Hello, world!

In case of log reference, each line will contain "header" (date and times):

  [2013-12-30 02:36:22 +0400 1388356582] {
  [2013-12-30 02:36:22 +0400 1388356582]   'room' => 'Sitting room',
  [2013-12-30 02:36:22 +0400 1388356582]   'colors' => [
  [2013-12-30 02:36:22 +0400 1388356582]     'orange',
  [2013-12-30 02:36:22 +0400 1388356582]     'purple',
  [2013-12-30 02:36:22 +0400 1388356582]     'black'
  [2013-12-30 02:36:22 +0400 1388356582]   ]
  [2013-12-30 02:36:22 +0400 1388356582] }

Log levels

FATAL

Logs messages at a FATAL level only.

ERROR

Logs messages classified as ERROR and FATAL.

WARNING

Logs messages classified as WARNING, ERROR and FATAL.

INFO

Logs messages classified as INFO, WARNING, ERROR and FATAL.

DEBUG

Logs messages classified as DEBUG, INFO, WARNING, ERROR and FATAL.

VERBOSE

Logs messages classified as VERBOSE, DEBUG, INFO, WARNING, ERROR and FATAL.

Messages on levels: FATAL, ERROR and WARNING go to error log; INFO, DEBUG and VERBOSE go to messages log.

EXPORTED FUNCTIONS

log_fatal (@messages)

Logs @messages with level FATAL.

log_error (@messages)

Logs @messages with level ERROR.

log_warning (@messages)

Logs @messages with level WARNING.

log_info (@messages)

Logs @messages with level INFO.

log_debug (@messages)

Logs @messages with level DEBUG.

log_verbose (@messages)

Logs @messages with level VERBOSE.

FUNCTIONS

write_to_fh ($fh, @messages)

Write @messages to file handle $fh.

ERRORS

Unable to update log '%s': %s

Where %s is log filename and %s is reason message.

Fires when unable to open or write to log file.

Invalid file handle

Fires when call write_to_fh with invalid file handle.

FILES

log/messages.log

Default log file with messages.

log/errors.log

Default log file with errors.

BUGS

Please report any bugs or feature requests to https://rt.cpan.org/Public/Bug/Report.html?Queue=Crane or to https://github.com/temoon/crane/issues.

AUTHOR

Tema Novikov, <novikov.tema@gmail.com>

COPYRIGHT AND LICENSE

Copyright (C) 2013-2014 Tema Novikov.

This library is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0. For details, see the full text of the license in the file LICENSE.

SEE ALSO

1 POD Error

The following errors were encountered while parsing the POD:

Around line 242:

Non-ASCII character seen before =encoding in '±hhmm.'. Assuming UTF-8