/usr/share/perl5/MooX/Log/Any.pm is in libmoox-log-any-perl 0.001-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | package MooX::Log::Any;
# ABSTRACT: Role to add Log::Any
use Moo::Role;
use Log::Any;
local $| = 1;
has 'log' => (
is => 'ro',
# isa => 'Log::Any::Adapter::Base',
lazy => 1,
default => sub { Log::Any->get_logger(); },
);
sub logger {
my $self=shift;
return $self->log;
}
1;
=head1 SYNOPSIS
package MyApp;
use Moo;
with 'MooX::Log::Any';
sub something {
my ($self) = @_;
$self->log->debug("started bar"); ### logs with default class catergory "MyApp"
$self->log->error("started bar"); ### logs with default class catergory "MyApp"
}
=head1 DESCRIPTION
A logging role building a very lightweight wrapper to L<Log::Any> for use with your L<Moo> or L<Moose> classes.
Connectibng a Log::Any::Adapter should be performed prior to logging the first log message, otherwise nothing will happen, just like with Log::Any
Using the logger within a class is as simple as consuming a role:
package MyClass;
use Moo;
with 'MooX::Log::Any';
sub dummy {
my $self = shift;
$self->log->info("Dummy log entry");
}
The logger needs to be setup before using the logger, which could happen in the main application:
package main;
use Log::Any::Adapter;
# Send all logs to Log::Log4perl
Log::Any::Adapter->set('Log4perl')
use MyClass;
my $myclass = MyClass->new();
$myclass->log->info("In my class"); # Access the log of the object
$myclass->dummy; # Will log "Dummy log entry"
=head1 ACCESSORS
=head2 log
The C<log> attribute holds the L<Log::Any::Adapter> object that implements all logging methods for the
defined log levels, such as C<debug> or C<error>. As this method is defined also in other logging
roles/systems like L<MooseX::Log::LogDispatch> this can be thought of as a common logging interface.
package MyApp::View::JSON;
extends 'MyApp::View';
with 'MooseX:Log::Log4perl';
sub bar {
$self->logger->info("Everything fine so far"); # logs a info message
$self->logger->debug("Something is fishy here"); # logs a debug message
}
=head2 logger([$category])
This is an alias for log.
=head1 SEE ALSO
L<Log::Any>, L<Moose>, L<Moo>
=head1 BUGS AND LIMITATIONS
Please report any bugs or feature requests to
C<bug-moosex-log4perl@rt.cpan.org>, or through the web interface at
L<http://rt.cpan.org>.
Or come bother us in C<#moose> on C<irc.perl.org>.
=head1 AUTHOR
Roland Lammel C<< <lammel@cpan.org> >>
Inspired by the work by Chris Prather C<< <perigrin@cpan.org> >> and Ash
Berlin C<< <ash@cpan.org> >> on L<MooseX::LogDispatch> and Roland Lammel C<< <lammel@cpan.org> >>
=head1 CONTRIBUTORS
In alphabetical order:
=over 2
=back
;
|