1MooseX::Log::Log4perl(3U)ser Contributed Perl DocumentatiMoonoseX::Log::Log4perl(3)
2
3
4

NAME

6       MooseX::Log::Log4perl - A Logging Role for Moose based on Log::Log4perl
7

VERSION

9       This document describes MooseX::Log::Log4perl version 0.30
10

SYNOPSIS

12        package MyApp;
13        use Moose;
14        use Log::Log4perl qw(:easy);
15
16        with 'MooseX::Log::Log4perl';
17
18        BEGIN {
19          Log::Log4perl->easy_init();
20        }
21
22        sub foo {
23          my ($self) = @_;
24          $self->log->debug("started bar");    ### logs with default class catergory "MyApp"
25          ...
26          $self->log('special')->info('bar');  ### logs with category special
27        }
28

DESCRIPTION

30       A logging role building a very lightweight wrapper to Log::Log4perl for
31       use with your Moose classes.  The initialization of the Log4perl
32       instance must be performed prior to logging the first log message.
33       Otherwise the default initialization will happen, probably not doing
34       the things you expect.
35
36       For compatibility the "logger" attribute can be accessed to use a
37       common interface for application logging.
38
39       For simple logging needs use MooseX::Log::Log4perl::Easy to directly
40       add log_<level> methods to your class instance.
41
42           $self->log_info("Dummy");
43

ACCESSORS

45   logger
46       The "logger" attribute holds the Log::Log4perl object that implements
47       all logging methods for the defined log levels, such as "debug" or
48       "error". As this method is defined also in other logging roles/systems
49       like MooseX::Log::LogDispatch this can be thought of as a common
50       logging interface.
51
52         package MyApp::View::JSON;
53
54         extends 'MyApp::View';
55         with 'MooseX:Log::Log4perl';
56
57         sub bar {
58           $self->logger->debug("Something could be crappy here");     # logs a debug message
59           $self->logger->debug("Something could be crappy here");     # logs a debug message
60         }
61
62   log([$category])
63       Basically the same as logger, but also allowing to change the log
64       category for this log message.
65
66        if ($myapp->log->is_debug()) {
67            $myapp->log->debug("Woot"); # category is class myapp
68        }
69        $myapp->log("TempCat")->info("Foobar"); # category TempCat
70        $myapp->log->info("Grumble"); # category class again myapp
71

SEE ALSO

73       Log::Log4perl, Moose, MooseX::LogDispatch
74

BUGS AND LIMITATIONS

76       Please report any bugs or feature requests to
77       "bug-moosex-log4perl@rt.cpan.org", or through the web interface at
78       <http://rt.cpan.org>.
79
80       Or come bother us in "#moose" on "irc.perl.org".
81

AUTHOR

83       Roland Lammel "<lammel@cpan.org>"
84
85       Inspired by the work by Chris Prather "<perigrin@cpan.org>" and Ash
86       Berlin "<ash@cpan.org>" on MooseX::LogDispatch
87
88       Thanks to Michael Schilli "<m@perlmeister.com>" for Log::Log4perl and
89       suggestions in the interface.
90
92       Copyright (c) 2008-2009, Roland Lammel "<lammel@cpan.org>",
93       http://www.quikit.at. Some rights reserved.
94
95       This module is free software; you can redistribute it and/or modify it
96       under the same terms as Perl itself. See perlartistic.
97
98
99
100perl v5.12.0                      2009-05-17          MooseX::Log::Log4perl(3)
Impressum