Jon Portnoy (PAUSE Custodial Account) > Bot-Cobalt-0.021002 > Bot::Cobalt::Logger::Output



Annotate this POD

View/Report Bugs
Module Version: 0.021002   Source   Latest Release: Bot-Cobalt-0.021003


Bot::Cobalt::Logger::Output - Log handler output manager


  ## Normally constructed by Bot::Cobalt::Logger

  my $log_output = Bot::Cobalt::Logger::Output->new(
    log_format  => $log_format,
    time_format => $time_format,
    'my_alias' => {
      type => 'File',
      file => $path_to_log,


This is the output manager for Bot::Cobalt::Logger, handling dispatch to log writers such as Bot::Cobalt::Logger::Output::File and Bot::Cobalt::Logger::Output::Term.



add() takes a list of aliases to add, mapped to a HASH containing the name of their writer class (type) and arguments to pass to the writer class constructor:

    ## Add a Bot::Cobalt::Logger::Output::File
    ## new() is passed 'file => $path_to_log'
    MyLogger => {
      type => 'File',
      file => $path_to_log,
    ## Add a Logger::Output::Term also:
    Screen => {
      type => 'Term',

The specified outputs will be initialized and tracked; their _write method is called when log messages are received.


del() takes a list of aliases to delete.

Returns the number of aliases actually deleted.


get() takes an alias and returns the appropriate writer object (or undef).


log_format can be specified at construction time or changed on the fly.

This is used to specify the actual layout of each individual logged message (for the default formatter; specific output classes may choose to override the formatter and disregard log_format).

Takes a "rplprintf" in Bot::Cobalt::Utils template string; normal rplprintf usage rules apply -- a replacement sequence starts with '%' and is terminated by either a space or a trailing '%'.

Defaults to "%level %time (%pkg%) %msg"

Replacement variables passed in to the template are:

  msg     Actual (concatenated) log message
  level   Level this message was logged to
  time    Current date and time (see time_format)
  pkg     Package this log method was called from
  file    File called from
  line    Line called from
  sub     Subroutine called from


time_format can be specified at construction time or changed on the fly.

This is used to create the '%time' template variable for "log_format".

It is fed to strftime to create a time/date string; see the documentation for strftime on your system for a complete list of usable replacement sequences.

Defaults to "%Y-%m-%d %H:%M:%S"

Commonly used replacement sequences include:

  %Y   Current year including century.  
  %m   Current month (as a number)
  %d   Current day of the month.

  %A   Full weekday name
  %a   Abbreviated weekday name
  %B   Full month name
  %b   Abbreviated month name

  %H   Hour of the day (on a 24-hour clock)
  %I   Hour of the day (on a 12-hour clock)
  %p   'AM' or 'PM' indication
  %M   Current minute
  %S   Current second
  %Z   Current timezone

  %s   Seconds since epoch ("Unix time")
  %%   Literal %


Jon Portnoy <>

syntax highlighting: