| 1 |
Log::Any |
| 2 |
|
| 3 |
"Log::Any" provides a standard log production API for modules. |
| 4 |
Log::Any::Adapter allows applications to choose the mechanism for log |
| 5 |
consumption, whether screen, file or another logging mechanism like |
| 6 |
Log::Dispatch or Log::Log4perl. |
| 7 |
|
| 8 |
Many modules have something interesting to say. Unfortunately there is |
| 9 |
no standard way for them to say it - some output to STDERR, others to |
| 10 |
"warn", others to custom file logs. And there is no standard way to get |
| 11 |
a module to start talking - sometimes you must call a uniquely named |
| 12 |
method, other times set a package variable. |
| 13 |
|
| 14 |
This being Perl, there are many logging mechanisms available on CPAN. |
| 15 |
Each has their pros and cons. Unfortunately, the existence of so many |
| 16 |
mechanisms makes it difficult for a CPAN author to commit his/her users |
| 17 |
to one of them. This may be why many CPAN modules invent their own |
| 18 |
logging or choose not to log at all. |
| 19 |
|
| 20 |
To untangle this situation, we must separate the two parts of a logging |
| 21 |
API. The first, *log production*, includes methods to output logs (like |
| 22 |
"$log->debug") and methods to inspect whether a log level is activated |
| 23 |
(like "$log->is_debug"). This is generally all that CPAN modules care |
| 24 |
about. The second, *log consumption*, includes a way to configure where |
| 25 |
logging goes (a file, the screen, etc.) and the code to send it there. |
| 26 |
This choice generally belongs to the application. |
| 27 |
|
| 28 |
A CPAN module uses "Log::Any" to get a log producer object. An |
| 29 |
application, in turn, may choose one or more logging mechanisms via |
| 30 |
Log::Any::Adapter, or none at all. |
| 31 |
|
| 32 |
"Log::Any" has a very tiny footprint and no dependencies beyond Perl |
| 33 |
5.8.1, which makes it appropriate for even small CPAN modules to use. It |
| 34 |
defaults to 'null' logging activity, so a module can safely log without |
| 35 |
worrying about whether the application has chosen (or will ever choose) |
| 36 |
a logging mechanism. |
| 37 |
|
| 38 |
See <http://www.openswartz.com/2007/09/06/standard-logging-api/> for the |
| 39 |
original post proposing this module. |
| 40 |
|
| 41 |
INSTALLATION |
| 42 |
|
| 43 |
This is a Perl module distribution. It should be installed with whichever |
| 44 |
tool you use to manage your installation of Perl, e.g. any of |
| 45 |
|
| 46 |
cpanm . |
| 47 |
cpan . |
| 48 |
cpanp -i . |
| 49 |
|
| 50 |
Consult http://www.cpan.org/modules/INSTALL.html for further instruction. |
| 51 |
Should you wish to install this module manually, the procedure is |
| 52 |
|
| 53 |
perl Makefile.PL |
| 54 |
make |
| 55 |
make test |
| 56 |
make install |
| 57 |
|
| 58 |
COPYRIGHT AND LICENSE |
| 59 |
|
| 60 |
This software is copyright (c) 2017 by Jonathan Swartz, David Golden, |
| 61 |
and Doug Bell. |
| 62 |
|
| 63 |
This is free software; you can redistribute it and/or modify it under |
| 64 |
the same terms as the Perl 5 programming language system itself. |