Jon Portnoy > Bot-Cobalt-0.016000 > Bot::Cobalt::Logger

Download:
Bot-Cobalt-0.016000.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.016000   Source   Latest Release: Bot-Cobalt-0.016002

NAME ^

Bot::Cobalt::Logger - Log handler for Bot::Cobalt

SYNOPSIS ^

  my $logger = Bot::Cobalt::Logger->new(
    ## Required, one of: debug info warn error
    level => 'info',
  
    ## Optional, passed to Bot::Cobalt::Logger::Output
    time_format => "%Y/%m/%d %H:%M:%S"
    log_format  => "%time% %pkg% (%level%) %msg%"
  );

  ## Add outputs
  ## (See Bot::Cobalt::Logger::Output for details)
  $logger->output->add(
    'Output::File' =>
      { file => $path_to_log },

    'Output::Term' =>
      { },
  );

  ## Log messages
  $logger->debug("Debugging message", @more_info );
  $logger->info("Informative message");
  $logger->warn("Warning message");
  $logger->error("Error message");

DESCRIPTION ^

This is the log handler for Bot::Cobalt.

Configured outputs must be added before log messages actually go anywhere (see the "SYNOPSIS"). See Bot::Cobalt::Logger::Output for details.

Log Levels

A level is required at construction-time; messages logged to the specified level or any level below it will be recorded.

For example, a level of 'warn' will discard log messages to 'debug' and 'info' and report only 'warn' and 'error' messages.

Valid levels, from high to low:

  debug
  info
  warn
  error

These should be called as methods to log to the appropriate level:

  $logger->info("This is some information");

If a list is provided, it will be concatenated with an empty space between items:

  $logger->info("Some info", "more info");

Methods

level

Returns the currently tracked log level.

set_level

Changes the current log level.

time_format

Sets a date/time formatting string to be fed to strftime -- see Bot::Cobalt::Logger::Output

log_format

Sets a formatting template string for log messages -- see Bot::Cobalt::Logger::Output

output

Returns the Bot::Cobalt::Logger::Output object.

AUTHOR ^

Jon Portnoy <avenj@cobaltirc.org>

syntax highlighting: