The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

MooseX::LogDispatch - A Logging Role for Moose

VERSION

This document describes MooseX::LogDispatch version 1.0000

SYNOPSIS

    package MyApp;
    use Moose;
    use MooseX::LogDispatch;
    
    with Logger();

    sub foo { 
        my ($self) = @_;
        $self->logger->debug("started foo");
        ....
        $self->logger->debug('ending foo');
    }
  

DESCRIPTION

Log::Dispatch role for use with your Moose classes.

EXPORTS

Logger(%options)

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.

The following options are understood

config

A suffix of the role you wish to use to configure the Logger. MooseX::LogDispatch::Configurator:: is prepended to this value.

Two roles are included in the dist - see "LOGGER ROLES"

interface

Similar to config, but this controls the interfaces presented. See "INTERFACE ROLES" for details

ACCESSORS

logger

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.

LOGGER ROLES

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:

      package MybjectWithLog;
    
      use Moose;
    
      with Logger(config => 'FileBased');
    
      ... 
    
      # Later on
      my $obj = MyObjectWithLog->new( config_filename => '/etc/project.logger.cfg');

INTERFACE ROLES

  • Default - gives you a logger attribute which has methods to log at various levels.

  • 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.

BUGS AND LIMITATIONS

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.

Or come bother us in #moose on irc.perl.org.

AUTHOR

Ash Berlin <ash@cpan.org>

Based on work by Chris Prather <perigrin@cpan.org>

LICENCE AND COPYRIGHT

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.