/usr/share/doc/libmoox-role-logger-perl/README is in libmoox-role-logger-perl 0.005-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 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | NAME
MooX::Role::Logger - Provide logging via Log::Any
VERSION
version 0.005
SYNOPSIS
In your modules:
package MyModule;
use Moose;
with 'MooX::Role::Logger';
sub run {
my ($self) = @_;
$self->cry;
}
sub cry {
my ($self) = @_;
$self->_logger->info("I'm sad");
}
In your application:
use MyModule;
use Log::Any::Adapter ('File', '/path/to/file.log');
MyModule->run;
DESCRIPTION
This role provides universal logging via Log::Any. The class using this
role doesn't need to know or care about the details of log
configuration, implementation or destination.
Use it when you want your module to offer logging capabilities, but
don't know who is going to use your module or what kind of logging they
will implement. This role lets you do your part and leaves actual log
setup and routing to someone else.
The application that ultimately uses your module can then choose to
direct log messages somewhere based on its own needs and configuration
with Log::Any::Adapter.
This role is based on Moo so it should work with either Moo or Moose
based classes.
USAGE
Testing
Testing with Log::Any is pretty easy, thanks to Log::Any::Test. Just
load that before Log::Any loads and your log messages get sent to a test
adapter that includes testing methods:
use Test::More 0.96;
use Log::Any::Test;
use Log::Any qw/$log/;
use lib 't/lib';
use MyModule;
MyModule->new->cry;
$log->contains_ok( qr/I'm sad/, "got log message" );
done_testing;
Customizing
If you have a whole set of classes that should log with a single
category, create your own role and set the "_build__logger_category"
there:
package MyLibrary::Role::Logger;
use Moo::Role;
with 'MooX::Role::Logger';
sub _build__logger_category { "MyLibrary" }
Then in your other classes, use your custom role:
package MyLibrary::Foo;
use Moo;
with 'MyLibrary::Role::Logger'
METHODS
_logger
Returns a logging object. See Log::Any for a list of logging methods it
accepts.
_build__logger_category
Override to set the category used for logging. Defaults to the class
name of the object (which could be a subclass). You can override to lock
it to a particular name:
sub _build__logger_category { __PACKAGE__ }
SEE ALSO
Since MooX::Role::Logger is universal, you have to use it with one of
several Log::Any::Adapter classes:
* Log::Any::Adapter::File
* Log::Any::Adapter::Stderr
* Log::Any::Adapter::Stdout
* Log::Any::Adapter::ScreenColoredLevel
* Log::Any::Adapter::Dispatch
* Log::Any::Adapter::Syslog
* Log::Any::Adapter::Log4perl
These other logging roles are specific to particular logging packages,
rather than being universal:
* MooseX::LazyLogDispatch
* MooseX::Log::Log4perl
* MooseX::LogDispatch
* MooseX::Role::LogHandler
* MooseX::Role::Loggable (uses Log::Dispatchouli)
* Role::Log::Syslog::Fast
SUPPORT
Bugs / Feature Requests
Please report any bugs or feature requests through the issue tracker at
<https://github.com/dagolden/MooX-Role-Logger/issues>. You will be
notified automatically of any progress on your issue.
Source Code
This is open source software. The code repository is available for
public review and contribution under the terms of the license.
<https://github.com/dagolden/MooX-Role-Logger>
git clone https://github.com/dagolden/MooX-Role-Logger.git
AUTHOR
David Golden <dagolden@cpan.org>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2013 by David Golden.
This is free software, licensed under:
The Apache License, Version 2.0, January 2004
|