NAME
MooseX::Log::Log4perl - A Logging Role for Moose based on Log::Log4perl
VERSION
This document describes MooseX::Log::Log4perl version 0.1
SYNOPSIS
package MyApp;
use Moose;
use Log::Log4perl qw(:easy);
with MooseX::Log::Log4perl;
BEGIN {
Log::Log4perl->easy_init();
}
sub foo {
my ($self) = @_;
$self->log->debug("started bar"); ### logs with default class catergory "MyApp"
...
$self->log('special')->info('bar'); ### logs with category special
}
DESCRIPTION
A logging role building a very lightweight wrapper to Log::Log4perl for use with your Moose classes. The initialization of the Log4perl instance must be performed prior to logging the first log message. Otherwise the default initialization will happen, probably not doing the things you expect.
ACCESSORS
logger
This is the main Log::Log4perl object that does all the work. It has methods for each of the log levels, such as debug
or error
.
log
A shorter alias for logger, but also allowing to change the log category this method call.
if ($myapp->log->is_debug()) {
$myapp->log->debug("Woot"); # category is class myapp
}
$myapp->log("TempCat")->info("Foobar"); # category TempCat
$myapp->log->info("Grumble"); # category class again myapp
SEE ALSO
L<Log::Log4perl>, L<Moose>, L<MooseX::LogDispatch>, L<Moose>
BUGS AND LIMITATIONS
Please report any bugs or feature requests to bug-moosex-log4perl@rt.cpan.org
, or through the web interface at http://rt.cpan.org.
Or come bother us in #moose
on irc.perl.org
.
AUTHOR
Roland Lammel <lammel@cpan.org>
Inspired by the work by Chris Prather <perigrin@cpan.org>
and Ash Berlin <ash@cpan.org>
on MooseX::LogDispatch
LICENCE AND COPYRIGHT
Copyright (c) 2009, Roland Lammel <lammel@cpan.org>
. Some rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.