Log::Dispatch::Channels - Adds separate logging channels to Log::Dispatch


Log-Dispatch-Channels documentation  | view source Contained in the Log-Dispatch-Channels distribution.

Index


VERSION

Top

version 0.01

SYNOPSIS

Top

  use Log::Dispatch::Channels;

  my $logger = Log::Dispatch::Channels->new;
  $logger->add_channel('foo');
  my $timestamper = sub { my %p = @_; return time . $p{message}; };
  $logger->add_channel('bar', callbacks => $timestamper);
  $logger->add(Log::Dispatch::File->new(channels  => 'foo',
                                        name      => 'foo',
                                        min_level => 'debug',
                                        filename  => 'foo.log'));
  $logger->add(Log::Dispatch::Null->new(channels  => 'bar',
                                        name      => 'bar',
                                        min_level => 'debug'));
  $logger->add(Log::Dispatch::File->new(channels  => [qw/foo bar/],
                                        name      => 'errors',
                                        min_level => 'error',
                                        filename  => 'error.log'));
  $logger->log(channels => 'foo', level => 'debug',
               message => 'For foo');
  $logger->log(channels => 'bar', level => 'error',
               message => 'For bar and errors');

DESCRIPTION

Top

This module manages a set of Log::Dispatch objects, treating them as separate message channels to which messages can be logged. These objects can share Log::Dispatch::Output objects, to allow for logging to multiple places simultaneously and automatically.

METHODS

Top

new()

Returns a new Log::Dispatch::Channels object.

add_channel($NAME, @ARGS)

Adds a new message channel named $NAME. This channel is actually a Log::Dispatch object, and @ARGS is forwarded on to the Log::Dispatch constructor.

remove_channel($NAME)

Removes the channel named $NAME and returns it.

add($OUTPUT[, channels => $NAMES])

Adds $OUTPUT (which is a Log::Dispatch::Output object), and also adds it to each channel named in $NAMES. $NAMES can be a string specifying a single channel, an arrayref of strings specifying multiple channels, or left out to add the output to all channels (this applies for each function taking a 'channels' argument).

remove($NAME)

Removes the output named $NAME from the object and from each of the channels, and then returns it.

log([channels => $NAMES,] %ARGS)

Forwards %ARGS on to the log method of each channel listed in $NAMES.

log_and_die([channels => $NAMES,] %ARGS)

Forwards %ARGS on to the log_and_die method of each channel listed in $NAMES.

log_and_croak([channels => $NAMES,] %ARGS)

Forwards %ARGS on to the log_and_croak method of each channel listed in $NAMES.

log_to(name => $NAME, %ARGS)

Forwards %ARGS on to the log method of the output named $NAME.

would_log($LEVEL[, channels => $NAMES])

Returns true if any channel named in $NAMES would log a message of level $LEVEL.

output($NAME)

Returns the Log::Dispatch::Output object named $NAME.

channel($NAME)

Returns the Log::Dispatch object named $NAME.

AUTHOR

Top

  Jesse Luehrs <doy at tozt dot net>

COPYRIGHT AND LICENSE

Top

TODO

Top

Allow top level callbacks on the Log::Dispatcher::Channels object

SEE ALSO

Top

Log::Dispatch

BUGS

Top

No known bugs.

Please report any bugs through RT: email bug-log-dispatch-channels at rt.cpan.org, or browse to http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Log-Dispatch-Channels.

SUPPORT

Top

You can find this documentation for this module with the perldoc command.

    perldoc Log::Dispatch::Channels

You can also look for information at:

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/Log-Dispatch-Channels

* CPAN Ratings

http://cpanratings.perl.org/d/Log-Dispatch-Channels

* RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=Log-Dispatch-Channels

* Search CPAN

http://search.cpan.org/dist/Log-Dispatch-Channels


Log-Dispatch-Channels documentation  | view source Contained in the Log-Dispatch-Channels distribution.