1MooX::Log::Any(3)     User Contributed Perl Documentation    MooX::Log::Any(3)
2
3
4

NAME

6       MooX::Log::Any - Role to add Log::Any
7

VERSION

9       version 0.004004
10

DESCRIPTION

12       A logging role building a very lightweight wrapper to Log::Any for use
13       with your Moo or Moose classes.  Connecting a Log::Any::Adapter should
14       be performed prior to logging the first log message, otherwise nothing
15       will happen, just like with Log::Any
16
17       Using the logger within a class is as simple as consuming a role:
18
19           package MyClass;
20           use Moo;
21           with 'MooX::Log::Any';
22
23           sub dummy {
24               my $self = shift;
25               $self->log->info("Dummy log entry");
26           }
27
28       The logger needs to be setup before using the logger, which could
29       happen in the main application:
30
31           package main;
32           use Log::Any::Adapter;
33           # Send all logs to Log::Log4perl
34           Log::Any::Adapter->set('Log4perl')
35
36           use MyClass;
37           my $myclass = MyClass->new();
38           $myclass->log->info("In my class"); # Access the log of the object
39           $myclass->dummy;                    # Will log "Dummy log entry"
40

SYNOPSIS;

42           package MyApp;
43           use Moo;
44
45           with 'MooX::Log::Any';
46
47           sub something {
48               my ($self) = @_;
49               $self->log->debug("started bar");    ### logs with default class catergory "MyApp"
50               $self->log->error("started bar");    ### logs with default class catergory "MyApp"
51           }
52

ACCESSORS

54   log
55       The "log" attribute holds the Log::Any::Adapter object that implements
56       all logging methods for the defined log levels, such as "debug" or
57       "error". As this method is defined also in other logging roles/systems
58       like MooseX::Log::LogDispatch this can be thought of as a common
59       logging interface.
60
61         package MyApp::View::JSON;
62
63         extends 'MyApp::View';
64         with 'MooseX:Log::Log4perl';
65
66         sub bar {
67           $self->logger->info("Everything fine so far");    # logs a info message
68           $self->logger->debug("Something is fishy here");  # logs a debug message
69         }
70
71   logger([$category])
72       This is an alias for log.
73

SEE ALSO

75       Log::Any, Moose, Moo
76
77   Inspired by
78       Inspired by the work by Chris Prather "<perigrin@cpan.org>" and Ash
79       Berlin "<ash@cpan.org>" on MooseX::LogDispatch and Roland Lammel
80       "<lammel@cpan.org>"
81

BUGS AND LIMITATIONS

83       Please report any bugs or feature requests through github
84       <https://github.com/cazador481/MooX-Log-Any>.
85

CONTRIBUTORS

87       In alphabetical order:
88
89       Jens Rehsack "rehsack@gmail.com>"
90

AUTHOR

92       Edward Ash <eddie+cpan@ashfamily.net>
93
95       This software is copyright (c) 2013 by Edward Ash.
96
97       This is free software; you can redistribute it and/or modify it under
98       the same terms as the Perl 5 programming language system itself.
99
100
101
102perl v5.28.0                      2016-01-20                 MooX::Log::Any(3)
Impressum