Log-Any-Adapter-0.11/000775 000765 000024 00000000000 12072327013 014753 5ustar00swartzstaff000000 000000 Log-Any-Adapter-0.11/Changes000644 000765 000024 00000002101 12072327013 016236 0ustar00swartzstaff000000 000000 Revision history for Log-Any-Adapter ** denotes an incompatible change 0.11 Jan 6, 2013 - Use IO::File in Adapter/File.pm to bring in autoflush - RT #81581 0.10 Oct 22, 2012 - Depend on Capture::Tiny 0.12 - RT #80287 (Andreas Koenig) 0.09 Aug 25, 2012 - add proper NAME sections to POD - RT #79216 (Gregor Herrmann) 0.08 Jul 17, 2012 - add simple built-in File, Stdout, and Stderr adapters, mainly to provide easy examples of usage that don't require additional packages - allow set() params to be passed to 'use Log::Any::Adapter' - allow adapter constructor to take any list of params, not necessarily a hash 0.07 Feb 22, 2012 - add Carp, Log::Any as prereqs 0.06 Jan 3, 2012 - switch from Scope::Guard to Guard, require Guard in deps 0.05 Dec 21, 2011 - remove release directory 0.04 Dec 21, 2011 - don't try to clean up entries during global destruction 0.03 Jan 5, 2010 - depend on Log::Any::Adapter::Core in Log-Any distribution 0.02 Oct 27, 2009 - Fix when loggers created before Log::Any::Adapter initialized 0.01 Oct 27, 2009 - Initial version Log-Any-Adapter-0.11/INSTALL000644 000765 000024 00000001723 12072327013 016005 0ustar00swartzstaff000000 000000 This is the Perl distribution Log-Any-Adapter. Installing Log-Any-Adapter is straightforward. ## Installation with cpanm If you have cpanm, you only need one line: % cpanm Log::Any::Adapter If you are installing into a system-wide directory, you may need to pass the "-S" flag to cpanm, which uses sudo to install the module: % cpanm -S Log::Any::Adapter ## Installing with the CPAN shell Alternatively, if your CPAN shell is set up, you should just be able to do: % cpan Log::Any::Adapter ## Manual installation As a last resort, you can manually install it. Download the tarball, untar it, then build it: % perl Makefile.PL % make && make test Then install it: % make install If you are installing into a system-wide directory, you may need to run: % sudo make install ## Documentation Log-Any-Adapter documentation is available as POD. You can run perldoc from a shell to read the documentation: % perldoc Log::Any::Adapter Log-Any-Adapter-0.11/lib/000775 000765 000024 00000000000 12072327013 015521 5ustar00swartzstaff000000 000000 Log-Any-Adapter-0.11/LICENSE000644 000765 000024 00000043664 12072327013 015773 0ustar00swartzstaff000000 000000 This software is copyright (c) 2011 by Jonathan Swartz. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2011 by Jonathan Swartz. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Suite 500, Boston, MA 02110-1335 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2011 by Jonathan Swartz. This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End Log-Any-Adapter-0.11/Makefile.PL000644 000765 000024 00000002172 12072327013 016725 0ustar00swartzstaff000000 000000 use strict; use warnings; use ExtUtils::MakeMaker 6.30; my %WriteMakefileArgs = ( "ABSTRACT" => "Tell Log::Any where to send its logs", "AUTHOR" => "Jonathan Swartz ", "BUILD_REQUIRES" => { "Test::More" => 0 }, "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => "6.30" }, "DISTNAME" => "Log-Any-Adapter", "EXE_FILES" => [], "LICENSE" => "perl", "NAME" => "Log::Any::Adapter", "PREREQ_PM" => { "Capture::Tiny" => "0.12", "Carp" => 0, "Devel::GlobalDestruction" => 0, "Guard" => 0, "IO::File" => 0, "Log::Any" => 0 }, "VERSION" => "0.11", "test" => { "TESTS" => "t/*.t" } ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.56) } ) { my $br = delete $WriteMakefileArgs{BUILD_REQUIRES}; my $pp = $WriteMakefileArgs{PREREQ_PM}; for my $mod ( keys %$br ) { if ( exists $pp->{$mod} ) { $pp->{$mod} = $br->{$mod} if $br->{$mod} > $pp->{$mod}; } else { $pp->{$mod} = $br->{$mod}; } } } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); Log-Any-Adapter-0.11/MANIFEST000644 000765 000024 00000000663 12072327013 016107 0ustar00swartzstaff000000 000000 Changes INSTALL LICENSE MANIFEST META.json META.yml Makefile.PL lib/Log/Any/Adapter.pm lib/Log/Any/Adapter/Base.pm lib/Log/Any/Adapter/Development.pod lib/Log/Any/Adapter/File.pm lib/Log/Any/Adapter/FileScreenBase.pm lib/Log/Any/Adapter/Stderr.pm lib/Log/Any/Adapter/Stdout.pm lib/Log/Any/Adapter/Test/Memory.pm lib/Log/Any/Adapter/Util.pm lib/Log/Any/Manager.pm t/00-load.t t/errors.t t/filescreen.t t/import.t t/memory.t t/sprintf.t Log-Any-Adapter-0.11/META.json000644 000765 000024 00000002767 12072327013 016406 0ustar00swartzstaff000000 000000 { "abstract" : "Tell Log::Any where to send its logs", "author" : [ "Jonathan Swartz " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 4.300028, CPAN::Meta::Converter version 2.120921", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Log-Any-Adapter", "no_index" : { "file" : [ "lib/Log/Any/Adapter/FileScreenBase.pm", "lib/Log/Any/Adapter/Test/Memory.pm", "lib/Log/Any/Adapter/Util.pm" ] }, "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "6.30" } }, "runtime" : { "requires" : { "Capture::Tiny" : "0.12", "Carp" : "0", "Devel::GlobalDestruction" : "0", "Guard" : "0", "IO::File" : "0", "Log::Any" : "0" } }, "test" : { "requires" : { "Test::More" : "0" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "mailto" : "bug-log-any-adapter@rt.cpan.org", "web" : "http://rt.cpan.org/NoAuth/Bugs.html?Dist=Log-Any-Adapter" }, "repository" : { "type" : "git", "url" : "git://github.com/jonswar/perl-log-any-adapter.git", "web" : "https://github.com/jonswar/perl-log-any-adapter" } }, "version" : "0.11" } Log-Any-Adapter-0.11/META.yml000644 000765 000024 00000001462 12072327013 016225 0ustar00swartzstaff000000 000000 --- abstract: 'Tell Log::Any where to send its logs' author: - 'Jonathan Swartz ' build_requires: Test::More: 0 configure_requires: ExtUtils::MakeMaker: 6.30 dynamic_config: 0 generated_by: 'Dist::Zilla version 4.300028, CPAN::Meta::Converter version 2.120921' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Log-Any-Adapter no_index: file: - lib/Log/Any/Adapter/FileScreenBase.pm - lib/Log/Any/Adapter/Test/Memory.pm - lib/Log/Any/Adapter/Util.pm requires: Capture::Tiny: 0.12 Carp: 0 Devel::GlobalDestruction: 0 Guard: 0 IO::File: 0 Log::Any: 0 resources: bugtracker: http://rt.cpan.org/NoAuth/Bugs.html?Dist=Log-Any-Adapter repository: git://github.com/jonswar/perl-log-any-adapter.git version: 0.11 Log-Any-Adapter-0.11/README000664 000765 000024 00000012543 12072327014 015641 0ustar00swartzstaff000000 000000 NAME Log::Any::Adapter -- Tell Log::Any where to send its logs VERSION version 0.11 SYNOPSIS # Log to a file, or stdout, or stderr for all categories # use Log::Any::Adapter ('File', '/path/to/file.log'); use Log::Any::Adapter ('Stdout'); use Log::Any::Adapter ('Stderr'); # Use Log::Log4perl for all categories # Log::Log4perl::init('/etc/log4perl.conf'); Log::Any::Adapter->set('Log4perl'); # Use Log::Dispatch for Foo::Baz # use Log::Dispatch; my $log = Log::Dispatch->new(outputs => [[ ... ]]); Log::Any::Adapter->set( { category => 'Foo::Baz' }, 'Dispatch', dispatcher => $log ); # Use Log::Dispatch::Config for Foo::Baz and its subcategories # use Log::Dispatch::Config; Log::Dispatch::Config->configure('/path/to/log.conf'); Log::Any::Adapter->set( { category => qr/^Foo::Baz/ }, 'Dispatch', dispatcher => Log::Dispatch::Config->instance() ); # Use your own adapter for all categories # Log::Any::Adapter->set('+My::Log::Any::Adapter', ...); DESCRIPTION The `Log-Any-Adapter' distribution implements Log::Any class methods to specify where logs should be sent. It is a separate distribution so as to keep `Log::Any' itself as simple and unchanging as possible. You do not have to use anything in this distribution explicitly. It will be auto-loaded when you call one of the methods below. ADAPTERS In order to use a logging mechanism with `Log::Any', there needs to be an adapter class for it. Typically this is named Log::Any::Adapter::*something*. Adapters in this distribution Three basic adapters come with this distribution -- File, Stdout and Stderr: use Log::Any::Adapter ('File', '/path/to/file.log'); use Log::Any::Adapter ('Stdout'); use Log::Any::Adapter ('Stderr'); # or use Log::Any::Adapter; Log::Any::Adapter->set('File', '/path/to/file.log'); Log::Any::Adapter->set('Stdout'); Log::Any::Adapter->set('Stderr'); All of them simply output the message and newline to the specified destination; a datestamp prefix is added in the `File' case. For anything more complex you'll want to use a more robust adapter from CPAN. Adapters on CPAN A sampling of adapters available on CPAN as of this writing: * Log::Any::Adapter::Log4perl * Log::Any::Adapter::Dispatch * Log::Any::Adapter::FileHandle * Log::Any::Adapter::Syslog You may find other adapters on CPAN by searching for "Log::Any::Adapter", or create your own adapter. See Log::Any::Adapter::Development for more information on the latter. SETTING AND REMOVING ADAPTERS Log::Any::Adapter->set ([options, ]adapter_name, adapter_params...) This method sets the adapter to use for all log categories, or for a particular set of categories. *adapter_name* is the name of an adapter. It is automatically prepended with "Log::Any::Adapter::". If instead you want to pass the full name of an adapter, prefix it with a "+". e.g. # Use My::Adapter class Log::Any::Adapter->set('+My::Adapter', arg => $value); *adapter_params* are passed along to the adapter constructor. See the documentation for the individual adapter classes for more information. An optional hash of *options* may be passed as the first argument. Options are: category A string containing a category name, or a regex (created with qr//) matching multiple categories. If not specified, all categories will be affected. lexically A reference to a lexical variable. When the variable goes out of scope, the adapter setting will be removed. e.g. { Log::Any::Adapter->set({lexically => \my $lex}, ...); # in effect here ... } # no longer in effect here `set' returns an entry object, which can be passed to `remove'. use Log::Any::Adapter (...) If you pass arguments to `use Log::Any::Adapter', it calls `Log::Any::Adapter->set' with those arguments. Log::Any::Adapter->remove (entry) Remove an *entry* previously returned by `set'. MULTIPLE ADAPTER SETTINGS `Log::Any' maintains a stack of entries created via `set'. When you get a logger for a particular category, `Log::Any' will work its way down the stack and use the first matching entry. Whenever the stack changes, any `Log::Any' loggers that have previously been created will automatically adjust to the new stack. For example: my $log = Log::Any->get_logger(); $log->error("aiggh!"); # this goes nowhere ... { Log::Any::Adapter->set({ lexically => \my $lex }, 'Log4perl'); $log->error("aiggh!"); # this goes to log4perl ... } $log->error("aiggh!"); # this goes nowhere again SEE ALSO Log::Any COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Jonathan Swartz. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Log-Any-Adapter-0.11/t/000775 000765 000024 00000000000 12072327013 015216 5ustar00swartzstaff000000 000000 Log-Any-Adapter-0.11/t/00-load.t000644 000765 000024 00000000213 12072327013 016531 0ustar00swartzstaff000000 000000 #!/usr/bin/perl use Test::More tests => 1; BEGIN { use_ok('Log::Any'); } diag("Testing Log::Any $Log::Any::VERSION, Perl $], $^X"); Log-Any-Adapter-0.11/t/errors.t000644 000765 000024 00000000654 12072327013 016722 0ustar00swartzstaff000000 000000 #!/usr/bin/perl use Test::More tests => 3; use Log::Any::Adapter; use strict; use warnings; eval { Log::Any::Adapter->set('Blah') }; like( $@, qr{Can't locate Log/Any/Adapter/Blah}, "adapter = Blah" ); eval { Log::Any::Adapter->set('+My::Adapter::Blah') }; like( $@, qr{Can't locate My/Adapter/Blah}, "adapter = +My::Adapter::Blah" ); eval { Log::Any::Adapter->set('') }; like( $@, qr{expected adapter name}, "adapter = ''" ); Log-Any-Adapter-0.11/t/filescreen.t000644 000765 000024 00000001575 12072327013 017530 0ustar00swartzstaff000000 000000 #!/usr/bin/perl use Test::More; use File::Temp qw(tempdir); use Log::Any::Adapter::Util qw(cmp_deeply read_file); use Capture::Tiny qw(capture_stdout capture_stderr); use strict; use warnings; require Log::Any::Adapter; { my $tempdir = tempdir( 'name-XXXX', TMPDIR => 1, CLEANUP => 1 ); my $file = "$tempdir/temp.log"; Log::Any::Adapter->set( 'File', $file ); my $log = Log::Any->get_logger(); $log->debug("to file"); like( scalar( read_file($file) ), qr/^\[.*\] to file\n$/, "file" ); } { Log::Any::Adapter->set('Stdout'); my $log = Log::Any->get_logger(); like( capture_stdout( sub { $log->debug("to stdout") } ), qr/^to stdout\n$/, "stdout" ); } { Log::Any::Adapter->set('Stderr'); my $log = Log::Any->get_logger(); like( capture_stderr( sub { $log->debug("to stderr") } ), qr/^to stderr\n$/, "stderr" ); } done_testing; Log-Any-Adapter-0.11/t/import.t000644 000765 000024 00000000441 12072327013 016712 0ustar00swartzstaff000000 000000 #!/usr/bin/perl use Capture::Tiny qw(capture_stdout); use Test::More; use Log::Any::Adapter qw(Stdout); use strict; use warnings; { my $log = Log::Any->get_logger(); like( capture_stdout( sub { $log->debug("to stdout") } ), qr/^to stdout\n$/, "stdout" ); } done_testing; Log-Any-Adapter-0.11/t/memory.t000644 000765 000024 00000006463 12072327013 016722 0ustar00swartzstaff000000 000000 #!/usr/bin/perl use Test::More; use Log::Any::Adapter::Util qw(cmp_deeply); use strict; use warnings; { package Foo; use Log::Any qw($log); sub log_debug { my ( $class, $text ) = @_; $log->debug($text) if $log->is_debug(); } } { package Bar; use Log::Any qw($log); sub log_info { my ( $class, $text ) = @_; $log->info($text) if $log->is_info(); } } require Log::Any::Adapter; $Baz::log = Log::Any->get_logger( category => 'Baz' ); my $main_log = Log::Any->get_logger(); is( $main_log, Log::Any->get_logger(), "memoization - no cat" ); is( $main_log, Log::Any->get_logger( category => 'main' ), "memoization - cat" ); my $memclass = 'Log::Any::Adapter::Test::Memory'; my $nullclass = 'Log::Any::Adapter::Null'; isa_ok( $Foo::log, $nullclass, 'Foo::log before set' ); isa_ok( $Bar::log, $nullclass, 'Bar::log before set' ); isa_ok( $Baz::log, $nullclass, 'Baz::log before set' ); isa_ok( $main_log, $nullclass, 'main_log before set' ); my $entry = Log::Any::Adapter->set( { category => qr/Foo|Bar/ }, "+$memclass" ); isa_ok( $Foo::log, $memclass, 'Foo::log after first set' ); isa_ok( $Bar::log, $memclass, 'Bar::log after first set' ); isa_ok( $Baz::log, $nullclass, 'Baz::log after first set' ); isa_ok( $main_log, $nullclass, 'main_log after first set' ); my $entry2 = Log::Any::Adapter->set( { category => qr/Baz|main/ }, "+$memclass" ); isa_ok( $Foo::log, $memclass, 'Foo::log after second set' ); isa_ok( $Bar::log, $memclass, 'Bar::log after second set' ); isa_ok( $Baz::log, $memclass, 'Baz::log after second set' ); isa_ok( $main_log, $memclass, 'main_log after second set' ); ok( $Foo::log ne $Bar::log, 'Foo::log and Bar::log are different' ); is( $main_log, Log::Any->get_logger(), "memoization - no cat" ); is( $main_log, Log::Any->get_logger( category => 'main' ), "memoization - cat" ); cmp_deeply( $Foo::log->{msgs}, [], 'Foo::log has empty buffer' ); cmp_deeply( $Bar::log->{msgs}, [], 'Bar::log has empty buffer' ); cmp_deeply( $main_log->{msgs}, [], 'Bar::log has empty buffer' ); ok( $Foo::log->{msgs} ne $Bar::log->{msgs}, 'Foo::log and Bar::log have different buffers' ); Foo->log_debug('for foo'); Bar->log_info('for bar'); $main_log->error('for main'); cmp_deeply( $Foo::log->{msgs}, [ { level => 'debug', category => 'Foo', text => 'for foo' } ], 'Foo log appeared in memory' ); cmp_deeply( $Bar::log->{msgs}, [ { level => 'info', category => 'Bar', text => 'for bar' } ], 'Foo log appeared in memory' ); cmp_deeply( $main_log->{msgs}, [ { level => 'error', category => 'main', text => 'for main' } ], 'main log appeared in memory' ); Log::Any::Adapter->remove($entry); isa_ok( $Foo::log, $nullclass, 'Foo::log' ); isa_ok( $Bar::log, $nullclass, 'Bar::log' ); isa_ok( $Baz::log, $memclass, 'Baz::log' ); isa_ok( $main_log, $memclass, 'main_log' ); Log::Any::Adapter->remove($entry2); isa_ok( $Foo::log, $nullclass, 'Foo::log' ); isa_ok( $Bar::log, $nullclass, 'Bar::log' ); isa_ok( $Baz::log, $nullclass, 'Baz::log' ); isa_ok( $main_log, $nullclass, 'main_log' ); { Log::Any::Adapter->set( { category => 'Foo', lexically => \my $lex }, "+$memclass" ); isa_ok( $Foo::log, $memclass, 'Foo::log in lexical scope' ); } isa_ok( $Foo::log, $nullclass, 'Foo::log outside lexical scope' ); done_testing; Log-Any-Adapter-0.11/t/sprintf.t000644 000765 000024 00000001266 12072327013 017073 0ustar00swartzstaff000000 000000 #!/usr/bin/perl use Test::More; use Log::Any::Adapter; use Log::Any::Adapter::Util qw(cmp_deeply); use strict; use warnings; Log::Any::Adapter->set('+Log::Any::Adapter::Test::Memory'); my $log = Log::Any->get_logger(); my @params = ( "args for %s: %s", 'app', [ 'foo', { 'bar' => 5 } ] ); $log->info(@params); $log->debugf(@params); cmp_deeply( $log->{msgs}, [ { text => "args for %s: %s", level => 'info', category => 'main' }, { text => "args for app: ['foo',{bar => 5}]", level => 'debug', category => 'main' } ], 'message was formatted' ); done_testing; Log-Any-Adapter-0.11/lib/Log/000775 000765 000024 00000000000 12072327013 016242 5ustar00swartzstaff000000 000000 Log-Any-Adapter-0.11/lib/Log/Any/000775 000765 000024 00000000000 12072327013 016771 5ustar00swartzstaff000000 000000 Log-Any-Adapter-0.11/lib/Log/Any/Adapter/000775 000765 000024 00000000000 12072327013 020351 5ustar00swartzstaff000000 000000 Log-Any-Adapter-0.11/lib/Log/Any/Adapter.pm000644 000765 000024 00000013375 12072327013 020716 0ustar00swartzstaff000000 000000 package Log::Any::Adapter; { $Log::Any::Adapter::VERSION = '0.11'; } use 5.006; use Log::Any; use Log::Any::Manager; use Log::Any::Adapter::Util qw(make_method); use strict; use warnings; # Checked by Log::Any to see if get_logger should be forwarded here # our $Initialized = 1; my $manager = Log::Any::Manager->new(); foreach my $method (qw(get_logger set remove)) { make_method( $method, sub { my $class = shift; return $manager->$method(@_); } ); } sub import { my $pkg = shift; $pkg->set(@_) if (@_); } 1; __END__ =pod =head1 NAME Log::Any::Adapter -- Tell Log::Any where to send its logs =head1 VERSION version 0.11 =head1 SYNOPSIS # Log to a file, or stdout, or stderr for all categories # use Log::Any::Adapter ('File', '/path/to/file.log'); use Log::Any::Adapter ('Stdout'); use Log::Any::Adapter ('Stderr'); # Use Log::Log4perl for all categories # Log::Log4perl::init('/etc/log4perl.conf'); Log::Any::Adapter->set('Log4perl'); # Use Log::Dispatch for Foo::Baz # use Log::Dispatch; my $log = Log::Dispatch->new(outputs => [[ ... ]]); Log::Any::Adapter->set( { category => 'Foo::Baz' }, 'Dispatch', dispatcher => $log ); # Use Log::Dispatch::Config for Foo::Baz and its subcategories # use Log::Dispatch::Config; Log::Dispatch::Config->configure('/path/to/log.conf'); Log::Any::Adapter->set( { category => qr/^Foo::Baz/ }, 'Dispatch', dispatcher => Log::Dispatch::Config->instance() ); # Use your own adapter for all categories # Log::Any::Adapter->set('+My::Log::Any::Adapter', ...); =head1 DESCRIPTION The C distribution implements L class methods to specify where logs should be sent. It is a separate distribution so as to keep C itself as simple and unchanging as possible. You do not have to use anything in this distribution explicitly. It will be auto-loaded when you call one of the methods below. =head1 ADAPTERS In order to use a logging mechanism with C, there needs to be an adapter class for it. Typically this is named Log::Any::Adapter::I. =head2 Adapters in this distribution Three basic adapters come with this distribution -- L, L and L: use Log::Any::Adapter ('File', '/path/to/file.log'); use Log::Any::Adapter ('Stdout'); use Log::Any::Adapter ('Stderr'); # or use Log::Any::Adapter; Log::Any::Adapter->set('File', '/path/to/file.log'); Log::Any::Adapter->set('Stdout'); Log::Any::Adapter->set('Stderr'); All of them simply output the message and newline to the specified destination; a datestamp prefix is added in the C case. For anything more complex you'll want to use a more robust adapter from CPAN. =head2 Adapters on CPAN A sampling of adapters available on CPAN as of this writing: =over =item * L =item * L =item * L =item * L =back You may find other adapters on CPAN by searching for "Log::Any::Adapter", or create your own adapter. See L for more information on the latter. =head1 SETTING AND REMOVING ADAPTERS =over =item Log::Any::Adapter->set ([options, ]adapter_name, adapter_params...) This method sets the adapter to use for all log categories, or for a particular set of categories. I is the name of an adapter. It is automatically prepended with "Log::Any::Adapter::". If instead you want to pass the full name of an adapter, prefix it with a "+". e.g. # Use My::Adapter class Log::Any::Adapter->set('+My::Adapter', arg => $value); I are passed along to the adapter constructor. See the documentation for the individual adapter classes for more information. An optional hash of I may be passed as the first argument. Options are: =over =item category A string containing a category name, or a regex (created with qr//) matching multiple categories. If not specified, all categories will be affected. =item lexically A reference to a lexical variable. When the variable goes out of scope, the adapter setting will be removed. e.g. { Log::Any::Adapter->set({lexically => \my $lex}, ...); # in effect here ... } # no longer in effect here =back C returns an entry object, which can be passed to C. =item use Log::Any::Adapter (...) If you pass arguments to C, it calls C<< Log::Any::Adapter->set >> with those arguments. =item Log::Any::Adapter->remove (entry) Remove an I previously returned by C. =back =head1 MULTIPLE ADAPTER SETTINGS C maintains a stack of entries created via C. When you get a logger for a particular category, C will work its way down the stack and use the first matching entry. Whenever the stack changes, any C loggers that have previously been created will automatically adjust to the new stack. For example: my $log = Log::Any->get_logger(); $log->error("aiggh!"); # this goes nowhere ... { Log::Any::Adapter->set({ lexically => \my $lex }, 'Log4perl'); $log->error("aiggh!"); # this goes to log4perl ... } $log->error("aiggh!"); # this goes nowhere again =head1 SEE ALSO L =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Jonathan Swartz. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Log-Any-Adapter-0.11/lib/Log/Any/Manager.pm000644 000765 000024 00000010053 12072327013 020676 0ustar00swartzstaff000000 000000 package Log::Any::Manager; { $Log::Any::Manager::VERSION = '0.11'; } use strict; use warnings; use Carp qw(croak); use Devel::GlobalDestruction; use Log::Any::Adapter::Util qw(require_dynamic); use Guard; sub new { my $class = shift; my $self = { entries => [] }; bless $self, $class; # Create the initial Null entry (this is always present) # $self->set('Null'); my $null_entry = $self->{entries}->[0]; # Start our category cache with any null adapters already returned from raw Log::Any # $self->{category_cache} = { map { ( $_ => { adapter => $Log::Any::NullAdapters{$_}, entry => $null_entry } ) } keys(%Log::Any::NullAdapters) }; return $self; } sub get_logger { my ( $self, $category ) = @_; # Create a new adapter for this category if it is not already in cache # my $category_cache = $self->{category_cache}; if ( !defined( $category_cache->{$category} ) ) { my $entry = $self->_choose_entry_for_category($category); my $adapter = $self->_new_adapter_for_entry( $entry, $category ); $category_cache->{$category} = { entry => $entry, adapter => $adapter }; } return $category_cache->{$category}->{adapter}; } sub _choose_entry_for_category { my ( $self, $category ) = @_; foreach my $entry ( @{ $self->{entries} } ) { if ( $category =~ $entry->{pattern} ) { return $entry; } } die "no entries matched '$category' - should not get here!"; } sub _new_adapter_for_entry { my ( $self, $entry, $category ) = @_; return $entry->{adapter_class} ->new( @{ $entry->{adapter_params} }, category => $category ); } sub set { my $self = shift; my $options; if ( ref( $_[0] ) eq 'HASH' ) { $options = shift(@_); } my ( $adapter_name, @adapter_params ) = @_; croak "expected adapter name" unless defined($adapter_name) && $adapter_name =~ /\S/; my $pattern = $options->{category}; if ( !defined($pattern) ) { $pattern = qr/.*/; } elsif ( !ref($pattern) ) { $pattern = qr/^\Q$pattern\E$/; } $adapter_name =~ s/^Log:://; # Log::Dispatch -> Dispatch, etc. my $adapter_class = ( substr( $adapter_name, 0, 1 ) eq '+' ? substr( $adapter_name, 1 ) : "Log::Any::Adapter::$adapter_name" ); require_dynamic($adapter_class); my $entry = $self->_new_entry( $pattern, $adapter_class, \@adapter_params ); unshift( @{ $self->{entries} }, $entry ); $self->_reselect_matching_adapters($pattern); if ( my $lex_ref = $options->{lexically} ) { $$lex_ref = Guard::guard { $self->remove($entry) if !in_global_destruction }; } return $entry; } sub remove { my ( $self, $entry ) = @_; my $pattern = $entry->{pattern}; my $size = scalar( @{ $self->{entries} } ); die "cannot remove bottom entry" if $entry eq $self->{entries}->[ $size - 1 ]; $self->{entries} = [ grep { $_ ne $entry } @{ $self->{entries} } ]; $self->_reselect_matching_adapters($pattern); } sub _new_entry { my ( $self, $pattern, $adapter_class, $adapter_params ) = @_; return { pattern => $pattern, adapter_class => $adapter_class, adapter_params => $adapter_params, }; } sub _reselect_matching_adapters { my ( $self, $pattern ) = @_; return if in_global_destruction; # Reselect adapter for each category matching $pattern # while ( my ( $category, $category_info ) = each( %{ $self->{category_cache} } ) ) { my $new_entry = $self->_choose_entry_for_category($category); if ( $new_entry ne $category_info->{entry} ) { my $new_adapter = $self->_new_adapter_for_entry( $new_entry, $category ); %{ $category_info->{adapter} } = %$new_adapter; bless( $category_info->{adapter}, ref($new_adapter) ); $category_info->{entry} = $new_entry; } } } 1; Log-Any-Adapter-0.11/lib/Log/Any/Adapter/Base.pm000644 000765 000024 00000002140 12072327013 021554 0ustar00swartzstaff000000 000000 package Log::Any::Adapter::Base; { $Log::Any::Adapter::Base::VERSION = '0.11'; } use Log::Any; use Log::Any::Adapter::Util qw(make_method); use strict; use warnings; use base qw(Log::Any::Adapter::Core); # In Log-Any distribution sub new { my $class = shift; my $self = {@_}; bless $self, $class; $self->init(@_); return $self; } sub init { } sub delegate_method_to_slot { my ( $class, $slot, $method, $adapter_method ) = @_; make_method( $method, sub { my $self = shift; return $self->{$slot}->$adapter_method(@_) }, $class ); } 1; __END__ =pod =head1 NAME Log::Any::Adapter::Base - Base class for Log::Any adapters =head1 VERSION version 0.11 =head1 DESCRIPTION This is the base class for Log::Any adapters. See L for information on developing Log::Any adapters. =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Jonathan Swartz. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Log-Any-Adapter-0.11/lib/Log/Any/Adapter/Development.pod000644 000765 000024 00000011350 12072327013 023335 0ustar00swartzstaff000000 000000 __END__ =pod =head1 NAME Log::Any::Adapter::Development -- Manual for developing new Log::Any adapters =head1 VERSION version 0.11 =head1 SYNOPSIS The adapter module: package Log::Any::Adapter::YAL; use strict; use warnings; use Log::Any::Adapter::Util qw(make_method); use base qw(Log::Any::Adapter::Base); # Optionally initialize object # sub init { my ($self) = @_; $self->{attr} = ...; } # Create logging methods: debug, info, etc. # foreach my $method ( Log::Any->logging_methods() ) { make_method($method, sub { ... }); } # Create detection methods: is_debug, is_info, etc. # foreach my $method ( Log::Any->detection_methods() ) { make_method($method, sub { ... }); } and the application: Log::Any->set_adapter('YAL'); =head1 DESCRIPTION This document describes how to implement a new Log::Any adapter. The easiest way to start is to look at the source of existing adapters, such as L and L. =head1 NAMING If you are going to publicly release your adapter, call it 'Log::Any::Adapter::I' so that users can use it with Log::Any->set_adapter(I); If it's an internal driver, you can call it whatever you like and use it like Log::Any->set_adapter('+My::Log::Adapter'); =head1 BASE CLASS All adapters must directly or indirectly inherit from L. =head1 METHODS =head2 Constructor The constructor (C) is provided by L. It will: =over =item * place any adapter arguments into a hash, along with the category =item * bless the hash into your subclass =item * call L which may be optionally provided by your subclass =back At this point, overriding the default constructor is not supported. Hopefully it will not be needed. The constructor is called whenever a log object is requested. e.g. If the application initializes Log::Any like so: Log::Any->set_adapter('Log::YAL', yal_object => $yal, depth => 3); and then a class requests a logger like so: package Foo; use Log::Any qw($log); Then C<$log> will be populated with the return value of: Log::Any::Adapter::Yal->new(yal_object => $yal, depth => 3, category => 'Foo'); This is memoized, so if the same category should be requested again (e.g. through a separate C call, the same object will be returned. Therefore, you should try to avoid anything non-deterministic in your L function. =head2 Required methods The following methods have no default implementation, and MUST be defined by your subclass: =over =item debug ($msg) =item info ($msg) =item notice ($msg) =item warning ($msg) =item error ($msg) =item critical ($msg) =item alert ($msg) =item emergency ($msg) These methods log a message at the specified level. To help generate these methods programmatically, you can get a list of the sub names with #__METHOD Log::Any->logging_methods =item is_debug () =item is_info () =item is_notice () =item is_warning () =item is_error () =item is_critical () =item is_alert () =item is_emergency () These methods return a boolean indicating whether the specified level is active. To help generate these methods programmatically, you can get a list of the sub names with #__METHOD Log::Any->detection_methods =back =head2 Optional methods The following methods have no default implementation but MAY be provided by your subclass: =over =item init () This is called after the adapter object is created and blessed into your class. It will be a hash containing the parameters that were passed to new(). Perform any necessary validation or initialization here. =back =head2 Support methods The following methods are useful for defining adapters: =over =item delegate_method_to_slot ($slot, $method, $adapter_method) Handle the specified $method by calling $adapter_method on the object contained in $self->{$slot}. See L and L for examples of usage. =item Log::Any->logging_methods Returns a list of logging methods: debug, info, etc. =item Log::Any->detection_methods Returns a list of detection methods: is_debug, is_info, etc. =item Log::Any->logging_and_detection_methods Returns a combined list of logging and detection methods. =back =head1 SEE ALSO L =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Jonathan Swartz. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Log-Any-Adapter-0.11/lib/Log/Any/Adapter/File.pm000644 000765 000024 00000002606 12072327013 021570 0ustar00swartzstaff000000 000000 package Log::Any::Adapter::File; { $Log::Any::Adapter::File::VERSION = '0.11'; } use IO::File; use strict; use warnings; use base qw(Log::Any::Adapter::FileScreenBase); sub new { my ( $class, $file ) = @_; return $class->SUPER::new( file => $file ); } sub init { my $self = shift; my $file = $self->{file}; open( $self->{fh}, ">>", $file ) or die "cannot open '$file' for append: $!"; $self->{fh}->autoflush(1); } __PACKAGE__->make_logging_methods( sub { my ( $self, $text ) = @_; my $msg = sprintf( "[%s] %s\n", scalar(localtime), $text ); $self->{fh}->print($msg); } ); 1; __END__ =pod =head1 NAME Log::Any::Adapter::File - Simple adapter for logging to files =head1 VERSION version 0.11 =head1 SYNOPSIS use Log::Any::Adapter ('File', '/path/to/file.log'); # or use Log::Any::Adapter; ... Log::Any::Adapter->set('File', '/path/to/file.log'); =head1 DESCRIPTION This simple built-in L adapter logs each message to the specified file, with a datestamp prefix and newline appended. The file is opened for append with autoflush on. Category and log level are ignored. =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Jonathan Swartz. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Log-Any-Adapter-0.11/lib/Log/Any/Adapter/FileScreenBase.pm000644 000765 000024 00000000744 12072327013 023524 0ustar00swartzstaff000000 000000 package Log::Any::Adapter::FileScreenBase; { $Log::Any::Adapter::FileScreenBase::VERSION = '0.11'; } use Log::Any::Adapter::Util qw(make_method); use strict; use warnings; use base qw(Log::Any::Adapter::Base); sub make_logging_methods { my ( $class, $code ) = @_; foreach my $method ( Log::Any->logging_methods() ) { make_method( $method, $code, $class ); } } foreach my $method ( Log::Any->detection_methods() ) { make_method( $method, sub { 1 } ); } 1; Log-Any-Adapter-0.11/lib/Log/Any/Adapter/Stderr.pm000644 000765 000024 00000001654 12072327013 022156 0ustar00swartzstaff000000 000000 package Log::Any::Adapter::Stderr; { $Log::Any::Adapter::Stderr::VERSION = '0.11'; } use strict; use warnings; use base qw(Log::Any::Adapter::FileScreenBase); __PACKAGE__->make_logging_methods( sub { my ( $self, $text ) = @_; print STDERR "$text\n"; } ); 1; __END__ =pod =head1 NAME Log::Any::Adapter::Stderr - Simple adapter for logging to STDERR =head1 VERSION version 0.11 =head1 SYNOPSIS use Log::Any::Adapter ('Stderr'); # or use Log::Any::Adapter; ... Log::Any::Adapter->set('Stderr'); =head1 DESCRIPTION This simple built-in L adapter logs each message to STDERR with a newline appended. Category and log level are ignored. =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Jonathan Swartz. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Log-Any-Adapter-0.11/lib/Log/Any/Adapter/Stdout.pm000644 000765 000024 00000001653 12072327013 022174 0ustar00swartzstaff000000 000000 package Log::Any::Adapter::Stdout; { $Log::Any::Adapter::Stdout::VERSION = '0.11'; } use strict; use warnings; use base qw(Log::Any::Adapter::FileScreenBase); __PACKAGE__->make_logging_methods( sub { my ( $self, $text ) = @_; print STDOUT "$text\n"; } ); 1; __END__ =pod =head1 NAME Log::Any::Adapter::Stdout - Simple adapter for logging to STDOUT =head1 VERSION version 0.11 =head1 SYNOPSIS use Log::Any::Adapter ('Stdout'); # or use Log::Any::Adapter; ... Log::Any::Adapter->set('Stdout'); =head1 DESCRIPTION This simple built-in L adapter logs each message to STDOUT with a newline appended. Category and log level are ignored. =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Jonathan Swartz. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Log-Any-Adapter-0.11/lib/Log/Any/Adapter/Test/000775 000765 000024 00000000000 12072327013 021270 5ustar00swartzstaff000000 000000 Log-Any-Adapter-0.11/lib/Log/Any/Adapter/Util.pm000644 000765 000024 00000002033 12072327013 021620 0ustar00swartzstaff000000 000000 package Log::Any::Adapter::Util; { $Log::Any::Adapter::Util::VERSION = '0.11'; } use Data::Dumper; use strict; use warnings; use base qw(Exporter); our @EXPORT_OK = qw( cmp_deeply dump_one_line make_method read_file require_dynamic ); sub cmp_deeply { my ( $ref1, $ref2, $name ) = @_; my $tb = Test::Builder->new(); $tb->is_eq( dump_one_line($ref1), dump_one_line($ref2), $name ); } sub dump_one_line { my ($value) = @_; return Data::Dumper->new( [$value] )->Indent(0)->Sortkeys(1)->Quotekeys(0) ->Terse(1)->Dump(); } sub make_method { my ( $method, $code, $pkg ) = @_; $pkg ||= caller(); no strict 'refs'; *{ $pkg . "::$method" } = $code; } sub read_file { my ($file) = @_; local $/ = undef; open( my $fh, '<', $file ) or die "cannot open '$file': $!"; my $contents = <$fh>; return $contents; } sub require_dynamic { my ($class) = @_; unless ( defined( eval "require $class" ) ) { ## no critic (ProhibitStringyEval) die $@; } } 1; Log-Any-Adapter-0.11/lib/Log/Any/Adapter/Test/Memory.pm000644 000765 000024 00000001433 12072327013 023075 0ustar00swartzstaff000000 000000 package Log::Any::Adapter::Test::Memory; { $Log::Any::Adapter::Test::Memory::VERSION = '0.11'; } use Log::Any::Adapter::Util qw(make_method); use strict; use warnings; use base qw(Log::Any::Adapter::Base); sub init { my ($self) = @_; $self->{msgs} = []; } foreach my $method ( Log::Any->logging_methods() ) { make_method( $method, sub { my ( $self, $text ) = @_; push( @{ $self->{msgs} }, { level => $method, category => $self->{category}, text => $text } ); } ); } foreach my $method ( Log::Any->detection_methods() ) { make_method( $method, sub { my ( $self, $msg ) = @_; return 1 } ); } 1;