MooseX::LogDispatch - A Logging Role for Moose
This document describes MooseX::LogDispatch version 1.0000
package MyApp; use Moose; use MooseX::LogDispatch; with Logger(); sub foo { my ($self) = @_; $self->logger->debug("started foo"); .... $self->logger->debug('ending foo'); }
Log::Dispatch role for use with your Moose classes.
This module will export the Logger method which can be used to load a specific set of MooseX::Logdispatch roles to implement a specific combination of features. It is meant to make things easier, but it is by no means the only way. You can still compose your roles by hand if you like.
Logger
The following options are understood
A suffix of the role you wish to use to configure the Logger. MooseX::LogDispatch::Configurator:: is prepended to this value.
MooseX::LogDispatch::Configurator::
Two roles are included in the dist - see "LOGGER ROLES"
Similar to config, but this controls the interfaces presented. See "INTERFACE ROLES" for details
config
This is the main Log::Dispatch::Config object that does all the work. It has methods for each of the log levels, such as debug or error.
debug
error
There are different ways of configuring a Log::Dispatch object. This distribution includes two roles:
Hardwired - hard-wired semi-sane defaults that logs everything to the screen. Enough to get you going, but you will probably not want to use this in the long run.
FileBased - Load config from a file using Log::Dispatch::Configurator::AppConfig
The config file is specified by using the config_filename attribute:
config_filename
package MybjectWithLog; use Moose; with Logger(config => 'FileBased'); ... # Later on my $obj = MyObjectWithLog->new( config_filename => '/etc/project.logger.cfg');
Default - gives you a logger attribute which has methods to log at various levels.
logger
Levels - will give you methods for each of the various log levels dirrectly on your object:
package MyLogger; use Moost; with Logger(interface => 'Levels'); ... my $logger = MyLogger->new; $logger->debug('Logger created');
There will also be a logger attribute.
No limitations have been reported.
Please report any bugs or feature requests to bug-moosex-logdispatch@rt.cpan.org, or through the web interface at http://rt.cpan.org.
bug-moosex-logdispatch@rt.cpan.org
Or come bother us in #moose on irc.perl.org.
#moose
irc.perl.org
Ash Berlin <ash@cpan.org>
<ash@cpan.org>
Based on work by Chris Prather <perigrin@cpan.org>
<perigrin@cpan.org>
Some development sponsored by Takkle Inc.
Copyright (c) 2007, Ash Berlin <ash@cpan.org>. Some rights reserved.
Copyright (c) 2007, Chris Prather <perigrin@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.
To install MooseX::LogDispatch, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::LogDispatch
CPAN shell
perl -MCPAN -e shell install MooseX::LogDispatch
For more information on module installation, please visit the detailed CPAN module installation guide.