Bot::Net::Log - logger for your bot net


Bot-Net documentation Contained in the Bot-Net distribution.

Index


Code Index:

NAME

Top

Bot::Net::Log - logger for your bot net

SYNOPSIS

Top

  Bot::Net->log->debug("Debug message.");
  Bot::Net->log->info("Info message.");
  Bot::Net->log->warn("Warning message.");
  Bot::Net->log->error("Error message.");
  Bot::Net->log->fatal("Fatal message.");

DESCRIPTION

The provides a logger using the Log::Log4perl facility, which has excellent configuration features. The configuration for your bot net is generally found in etc/log4perl.conf.

METHODS

Top

new

Creates the logger. In general, you never need to call this. Use this instead:

  my $log = Bot::Net->log;

get_logger NAME

Returns the named logger. In general, you never need to call this. Use this instead:

  my $log = Bot::Net->log;

or:

  my $log = Bot::Net->log('MyBotNet::Bot::CopyBot');

AUTHORS

Top

Andrew Sterling Hanenkamp <hanenkamp@cpan.org>

COPYRIGHT AND LICENSE

Top


Bot-Net documentation Contained in the Bot-Net distribution.
use strict;
use warnings;

package Bot::Net::Log;

use FileHandle;
use FindBin;
use Log::Log4perl;
use Readonly;

sub new {
    my $class = shift;

    # XXX Hack to get tests to work since it depends on the log messages
    # reported to flush... probably not good for production
    STDOUT->autoflush(1);
    STDERR->autoflush(1);

    my $config_file = Bot::Net::Config::_search_for_file('log4perl.conf');

    Log::Log4perl::init($config_file);
    bless {}, $class;
}

sub get_logger {
    my $self = shift;
    my $name = shift;
    return Log::Log4perl->get_logger($name);
}

1;