Log-Dispatchouli-2.009000755000766000024 012264314006 14116 5ustar00rjbsstaff000000000000README100644000766000024 57412264314006 15045 0ustar00rjbsstaff000000000000Log-Dispatchouli-2.009 This archive contains the distribution Log-Dispatchouli, version 2.009: a simple wrapper around Log::Dispatch This software is copyright (c) 2014 by Ricardo SIGNES. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. This README file was generated by Dist::Zilla::Plugin::Readme v5.010. Changes100644000766000024 750512264314006 15501 0ustar00rjbsstaff000000000000Log-Dispatchouli-2.009Revision history for Log-Dispatchouli 2.009 2014-01-11 14:14:11-05:00 America/New_York load the Proxy class earlier, to get it loaded prefork 2.008 2013-09-26 20:39:11 America/New_York fix test for JSON::PP, which doesn't always follow orders about spaces! (thanks, Dagfinn Ilmari Mannsåker!) 2.007 2013-09-25 22:12:22 America/New_York doc fixes and tests (thanks George Hartzell and Randy Stauner) 2.006 2013-04-05 15:02:05 America/New_York put the ->info, ->fatal, ->debug methods on proxies, too (thanks George Hartzell) 2.005 2011-04-07 23:16:40 America/New_York add log_file and log_path options 2.004 2011-01-21 15:52:41 America/New_York BUG FIX: it is okay to replace the default logger, always 2.003 2011-01-21 13:14:43 America/New_York add config_id to allow faking Global equality when testing 2.002 2011-01-14 17:51:16 America/New_York add env_value and env_prefix methods 2.001 2011-01-13 12:45:05 America/New_York greatly expanded tests and documentation for L::D::Global L::D now has "string_flogger" method to provide an alternate flogger 2.000 2010-11-23 18:48:53 America/New_York 1.102350 2010-08-23 08:55:17 America/New_York fix a bug in generating tempdirs for file logging (thanks, Sawyer X) 1.102220 2010-08-10 11:09:30 America/New_York added logger muting (mute, unmute, clear_muted, etc.) new_tester turns off log_pid by default internal simplification of Proxy 1.100712 2010-03-12 21:43:13 America/New_York add the quiet_fatal argument to suppress apparent double-logging to standard output and error streams 1.100711 2010-03-12 18:11:41 America/New_York 1.100710 2010-03-12 09:51:32 America/New_York add the Log::Dispatchouli::Proxy system get_prefix now always returns a scalar (undef, not ()) 1.100691 2010-03-10 17:10:53 America/New_York just like 1.100690, but passes its own tests! 1.100690 2010-03-10 14:24:59 America/New_York remove obsolete "list_name" alias to prefix object-level prefix no longer automatically ends in ": " 1.100681 2010-03-09 23:02:11 America/New_York rerelease with a tarball that isn't totally insane 1.100680 2010-03-09 22:47:23 America/New_York rewrite all log_ methods in terms of ->log ->log now includes the code formerly in the internal ->_log_at add a new per-message prefix system old-style prefix (to be removed) now handle multi-line messages * new prefix system is not yet documented, pending experimentation 1.100670 2010-03-08 19:15:30 America/New_York make env vars in code match env vars in docs 1.100660 2010-03-07 22:00:58 America/New_York add clear_events method loggers made with new_tester log to_self 1.100630 2010-03-04 18:41:13 America/New_York some more docs switch to Dist::Zilla for dist maintenance declare some previously missing prereqs 1.008 2010-02-22 ->fatal now redispatches to ->log_fatal 1.007 2010-02-22 ** THIS BREAKS BACKCOMPAT IN A TINY WAY ** ->debug now means ->log_debug ->is_debug and ->set_debug replace the old ->debug ->log_info is replaced by ->info 1.006 2010-02-21 add is_debug, is_info, is_fatal log_fatal logs as 'error' level change the way the undocumented "prefix" system works 1.005 2010-02-12 make Makefile.PL prereq match actual required versions 1.004 2010-02-10 allow multiple arguments to ->log and friends allow user to disable logging of pid 1.003 2009-01-15 relax a test that was complaining for no good reason LICENSE100644000766000024 4366112264314006 15236 0ustar00rjbsstaff000000000000Log-Dispatchouli-2.009This software is copyright (c) 2014 by Ricardo SIGNES. 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) 2014 by Ricardo SIGNES. 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) 2014 by Ricardo SIGNES. 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 dist.ini100644000766000024 26012264314006 15621 0ustar00rjbsstaff000000000000Log-Dispatchouli-2.009name = Log-Dispatchouli author = Ricardo SIGNES license = Perl_5 copyright_holder = Ricardo SIGNES [@RJBS] [Prereqs] Sys::Syslog = 0.16 ; native socket type t000755000766000024 012264314006 14302 5ustar00rjbsstaff000000000000Log-Dispatchouli-2.009file.t100644000766000024 160112264314006 15544 0ustar00rjbsstaff000000000000Log-Dispatchouli-2.009/tuse strict; use warnings; use Log::Dispatchouli; use Test::More 0.88; use File::Spec::Functions qw( catfile ); use File::Temp qw( tempdir ); my $tmpdir = tempdir( TMPDIR => 1, CLEANUP => 1 ); { { my $logger = Log::Dispatchouli->new({ log_pid => 1, ident => 't_file', to_file => 1, log_path => $tmpdir, }); isa_ok($logger, 'Log::Dispatchouli'); is($logger->ident, 't_file', '$logger->ident is available'); $logger->log([ "point: %s", {x=>1,y=>2} ]); } my ($log_file) = glob(catfile($tmpdir, 't_file.*')); ok -r $log_file, 'log file with ident name'; like slurp_file($log_file), qr/^.+? \[$$\] point: \{\{\{("[xy]": [12](, ?)?){2}\}\}\}$/, 'logged timestamp, pid, and hash'; } done_testing; sub slurp_file { my ($file) = @_; open my $fh, '<', $file or die "Failed to open $file: $!"; local $/; return <$fh>; } META.yml100644000766000024 2117412264314006 15475 0ustar00rjbsstaff000000000000Log-Dispatchouli-2.009--- abstract: 'a simple wrapper around Log::Dispatch' author: - 'Ricardo SIGNES ' build_requires: File::Spec::Functions: 0 File::Temp: 0 Test::Deep: 0 Test::Fatal: 0 Test::More: 0.96 base: 0 lib: 0 configure_requires: ExtUtils::MakeMaker: 6.30 dynamic_config: 0 generated_by: 'Dist::Zilla version 5.010, CPAN::Meta::Converter version 2.133380' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Log-Dispatchouli requires: Carp: 0 File::Spec: 0 Log::Dispatch: 0 Log::Dispatch::Array: 0 Log::Dispatch::File: 0 Log::Dispatch::Screen: 0 Log::Dispatch::Syslog: 0 Params::Util: 0 Scalar::Util: 0 String::Flogger: 0 Sub::Exporter: 0 Sub::Exporter::GlobExporter: 0.002 Sys::Syslog: 0.16 Try::Tiny: 0.04 overload: 0 strict: 0 warnings: 0 resources: bugtracker: https://github.com/rjbs/Log-Dispatchouli/issues homepage: https://github.com/rjbs/Log-Dispatchouli repository: https://github.com/rjbs/Log-Dispatchouli.git version: 2.009 x_Dist_Zilla: perl: version: 5.018002 plugins: - class: Dist::Zilla::Plugin::Git::GatherDir name: '@RJBS/Git::GatherDir' version: 2.019 - class: Dist::Zilla::Plugin::CheckPrereqsIndexed name: '@RJBS/CheckPrereqsIndexed' version: 0.010 - class: Dist::Zilla::Plugin::CheckExtraTests name: '@RJBS/CheckExtraTests' version: 0.016 - class: Dist::Zilla::Plugin::PromptIfStale config: Dist::Zilla::Plugin::PromptIfStale: check_all_plugins: 0 check_all_prereqs: 0 modules: - Dist::Zilla::PluginBundle::RJBS phase: build skip: [] name: '@RJBS/RJBS-Outdated' version: 0.015 - class: Dist::Zilla::Plugin::PromptIfStale config: Dist::Zilla::Plugin::PromptIfStale: check_all_plugins: 1 check_all_prereqs: 0 modules: [] phase: release skip: [] name: '@RJBS/CPAN-Outdated' version: 0.015 - class: Dist::Zilla::Plugin::PruneCruft name: '@RJBS/@Filter/PruneCruft' version: 5.010 - class: Dist::Zilla::Plugin::ManifestSkip name: '@RJBS/@Filter/ManifestSkip' version: 5.010 - class: Dist::Zilla::Plugin::MetaYAML name: '@RJBS/@Filter/MetaYAML' version: 5.010 - class: Dist::Zilla::Plugin::License name: '@RJBS/@Filter/License' version: 5.010 - class: Dist::Zilla::Plugin::Readme name: '@RJBS/@Filter/Readme' version: 5.010 - class: Dist::Zilla::Plugin::ExecDir name: '@RJBS/@Filter/ExecDir' version: 5.010 - class: Dist::Zilla::Plugin::ShareDir name: '@RJBS/@Filter/ShareDir' version: 5.010 - class: Dist::Zilla::Plugin::MakeMaker name: '@RJBS/@Filter/MakeMaker' version: 5.010 - class: Dist::Zilla::Plugin::Manifest name: '@RJBS/@Filter/Manifest' version: 5.010 - class: Dist::Zilla::Plugin::TestRelease name: '@RJBS/@Filter/TestRelease' version: 5.010 - class: Dist::Zilla::Plugin::ConfirmRelease name: '@RJBS/@Filter/ConfirmRelease' version: 5.010 - class: Dist::Zilla::Plugin::UploadToCPAN name: '@RJBS/@Filter/UploadToCPAN' version: 5.010 - class: Dist::Zilla::Plugin::AutoPrereqs name: '@RJBS/AutoPrereqs' version: 5.010 - class: Dist::Zilla::Plugin::Git::NextVersion name: '@RJBS/Git::NextVersion' version: 2.019 - class: Dist::Zilla::Plugin::PkgVersion name: '@RJBS/PkgVersion' version: 5.010 - class: Dist::Zilla::Plugin::MetaConfig name: '@RJBS/MetaConfig' version: 5.010 - class: Dist::Zilla::Plugin::MetaJSON name: '@RJBS/MetaJSON' version: 5.010 - class: Dist::Zilla::Plugin::NextRelease name: '@RJBS/NextRelease' version: 5.010 - class: Dist::Zilla::Plugin::Test::ChangesHasContent name: '@RJBS/Test::ChangesHasContent' version: 0.006 - class: Dist::Zilla::Plugin::PodSyntaxTests name: '@RJBS/PodSyntaxTests' version: 5.010 - class: Dist::Zilla::Plugin::ReportVersions::Tiny name: '@RJBS/ReportVersions::Tiny' version: 1.10 - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: test type: requires name: '@RJBS/TestMoreWithSubtests' version: 5.010 - class: Dist::Zilla::Plugin::PodWeaver config: Dist::Zilla::Plugin::PodWeaver: config_plugins: - '@RJBS' finder: - ':InstallModules' - ':ExecFiles' plugins: - class: Pod::Weaver::Plugin::EnsurePod5 name: '@CorePrep/EnsurePod5' version: 4.006 - class: Pod::Weaver::Plugin::H1Nester name: '@CorePrep/H1Nester' version: 4.006 - class: Pod::Weaver::Plugin::SingleEncoding name: '@RJBS/SingleEncoding' version: 4.006 - class: Pod::Weaver::Section::Name name: '@RJBS/Name' version: 4.006 - class: Pod::Weaver::Section::Version name: '@RJBS/Version' version: 4.006 - class: Pod::Weaver::Section::Region name: '@RJBS/Prelude' version: 4.006 - class: Pod::Weaver::Section::Generic name: '@RJBS/Synopsis' version: 4.006 - class: Pod::Weaver::Section::Generic name: '@RJBS/Description' version: 4.006 - class: Pod::Weaver::Section::Generic name: '@RJBS/Overview' version: 4.006 - class: Pod::Weaver::Section::Generic name: '@RJBS/Stability' version: 4.006 - class: Pod::Weaver::Section::Collect name: Attributes version: 4.006 - class: Pod::Weaver::Section::Collect name: Methods version: 4.006 - class: Pod::Weaver::Section::Collect name: Functions version: 4.006 - class: Pod::Weaver::Section::Leftovers name: '@RJBS/Leftovers' version: 4.006 - class: Pod::Weaver::Section::Region name: '@RJBS/postlude' version: 4.006 - class: Pod::Weaver::Section::Authors name: '@RJBS/Authors' version: 4.006 - class: Pod::Weaver::Section::Legal name: '@RJBS/Legal' version: 4.006 - class: Pod::Weaver::Plugin::Transformer name: '@RJBS/List' version: 4.006 name: '@RJBS/PodWeaver' version: 4.005 - class: Dist::Zilla::Plugin::GithubMeta name: '@RJBS/GithubMeta' version: 0.42 - class: Dist::Zilla::Plugin::Git::Check name: '@RJBS/@Git/Check' version: 2.019 - class: Dist::Zilla::Plugin::Git::Commit name: '@RJBS/@Git/Commit' version: 2.019 - class: Dist::Zilla::Plugin::Git::Tag name: '@RJBS/@Git/Tag' version: 2.019 - class: Dist::Zilla::Plugin::Git::Push name: '@RJBS/@Git/Push' version: 2.019 - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: runtime type: requires name: Prereqs version: 5.010 - class: Dist::Zilla::Plugin::FinderCode name: ':InstallModules' version: 5.010 - class: Dist::Zilla::Plugin::FinderCode name: ':IncModules' version: 5.010 - class: Dist::Zilla::Plugin::FinderCode name: ':TestFiles' version: 5.010 - class: Dist::Zilla::Plugin::FinderCode name: ':ExecFiles' version: 5.010 - class: Dist::Zilla::Plugin::FinderCode name: ':ShareFiles' version: 5.010 - class: Dist::Zilla::Plugin::FinderCode name: ':MainModule' version: 5.010 - class: Dist::Zilla::Plugin::FinderCode name: ':AllFiles' version: 5.010 - class: Dist::Zilla::Plugin::FinderCode name: ':NoFiles' version: 5.010 zilla: class: Dist::Zilla::Dist::Builder config: is_trial: 0 version: 5.010 MANIFEST100644000766000024 73412264314006 15314 0ustar00rjbsstaff000000000000Log-Dispatchouli-2.009# This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.010. Changes LICENSE MANIFEST META.json META.yml Makefile.PL README dist.ini lib/Log/Dispatchouli.pm lib/Log/Dispatchouli/Global.pm lib/Log/Dispatchouli/Proxy.pm t/000-report-versions-tiny.t t/basic.t t/env-value.t t/file.t t/global-subclass.t t/global.t t/lib/DDR/Child.pm t/lib/DDR/Parent.pm t/lib/SDR/Child.pm t/lib/SDR/Parent.pm t/proxy.t xt/release/changes_has_content.t xt/release/pod-syntax.t basic.t100644000766000024 763712264314006 15725 0ustar00rjbsstaff000000000000Log-Dispatchouli-2.009/tuse strict; use warnings; use Log::Dispatchouli; use Test::More 0.88; use Test::Deep; { my $logger = Log::Dispatchouli->new_tester({ log_pid => 1, ident => 't/basic.t', }); isa_ok($logger, 'Log::Dispatchouli'); is($logger->ident, 't/basic.t', '$logger->ident is available'); $logger->log([ "point: %s", {x=>1,y=>2} ]); $logger->log_debug('this will not get logged'); cmp_deeply( $logger->events, [ superhashof({ message => re(qr/$$.+\Qpoint: {{{"x": 1,\E\s?\Q"y": 2}}}\E\z/) }) ], "events with struts logged to self", ); eval { $logger->log_fatal([ 'this is good: %s', [ 1, 2, 3 ] ]) }; like($@, qr(good: \{\{\[), "log_fatal is fatal"); } { my $logger = Log::Dispatchouli->new_tester({ to_self => 1, log_pid => 0, }); isa_ok($logger, 'Log::Dispatchouli'); $logger->log([ "point: %s", {x=>1,y=>2} ]); $logger->log_debug('this will not get logged'); cmp_deeply( $logger->events, [ superhashof({ message => code(sub { index($_[0], $$) == -1 }), }) ], 'events with struts logged to self (no $$)', ); eval { $logger->log_fatal([ 'this is good: %s', [ 1, 2, 3 ] ]) }; like($@, qr(good: \{\{\[), "log_fatal is fatal"); } { my $logger = Log::Dispatchouli->new({ ident => 'foo', to_self => 1, log_pid => 0, }); $logger->log('foo'); cmp_deeply($logger->events, [ superhashof({ message =>'foo' }) ], 'log foo'); $logger->clear_events; cmp_deeply($logger->events, [ ], 'log empty after clear'); $logger->log('bar'); cmp_deeply($logger->events, [ superhashof({ message =>'bar' }) ], 'log bar'); $logger->log('foo'); cmp_deeply( $logger->events, [ superhashof({ message =>'bar' }), superhashof({ message =>'foo' }), ], 'log keeps accumulating', ); } { my $logger = Log::Dispatchouli->new({ ident => 'foo', to_self => 1, log_pid => 0, }); $logger->log([ '%s %s', '[foo]', [qw(foo)] ], ".."); is( $logger->events->[0]{message}, '[foo] {{["foo"]}} ..', "multi-arg logging", ); $logger->set_prefix('xyzzy: '); $logger->log('foo'); $logger->clear_prefix; $logger->log('bar'); is($logger->events->[1]{message}, 'xyzzy: foo', 'set a prefix'); is($logger->events->[2]{message}, 'bar', 'clear prefix'); } { my $logger = eval { Log::Dispatchouli->new; }; like($@, qr/no ident specified/, "can't make a logger without ident"); } { my $logger = Log::Dispatchouli->new({ ident => 'foo', to_self => 1, log_pid => 0, }); $logger->log({ prefix => '[ALERT] ' }, "foo\nbar\nbaz"); my $want_0 = <<'END_LOG'; [ALERT] foo [ALERT] bar [ALERT] baz END_LOG chomp $want_0; $logger->log( { prefix => sub { my $m = shift; my @lines = split /\n/, $m; $lines[0] = "<<< $lines[0]"; $lines[1] = "||| $lines[1]"; $lines[2] = ">>> $lines[2]"; return join "\n", @lines; }, }, "foo\nbar\nbaz", ); my $want_1 = <<'END_LOG'; <<< foo ||| bar >>> baz END_LOG chomp $want_1; is( $logger->events->[0]{message}, $want_0, "multi-line and prefix (string)", ); is( $logger->events->[1]{message}, $want_1, "multi-line and prefix (code)", ); } { my $logger = Log::Dispatchouli->new_tester({ debug => 1 }); $logger->log('info'); $logger->log('debug'); cmp_deeply( $logger->events, [ superhashof({ message => 'info' }), superhashof({ message => 'debug' }), ], 'info and debug while not muted', ); $logger->clear_events; $logger->mute; $logger->log('info'); $logger->log('debug'); cmp_deeply($logger->events, [ ], 'nothing logged while muted'); ok( ! eval { $logger->log_fatal('fatal'); 1}, "log_fatal still dies while muted", ); cmp_deeply( $logger->events, [ superhashof({ message => 'fatal' }) ], 'logged a fatal even while muted' ); } done_testing; proxy.t100644000766000024 573512264314006 16022 0ustar00rjbsstaff000000000000Log-Dispatchouli-2.009/tuse strict; use warnings; use Log::Dispatchouli; use Test::More 0.88; my $logger = Log::Dispatchouli->new_tester({ ident => 't/proxy.t', }); sub are_events { my ($comment, $want) = @_; my @have = map { $_->{message} } @{ $logger->events }; $logger->clear_events; is_deeply(\@have, $want, $comment); } $logger->log("1"); is($logger->ident, 't/proxy.t', '$logger->ident is available'); are_events("we can log a simple event", [ '1' ]); $logger->set_prefix("A: "); $logger->log("2"); are_events("simple log with prefix", [ 'A: 2', ]); my $proxy = $logger->proxy({ proxy_prefix => 'B: ', }); is($proxy->ident, 't/proxy.t', '$proxy->ident is available'); $proxy->log("3"); are_events("log with proxy with prefix", [ 'A: B: 3', ]); $proxy->set_prefix('C: '); $proxy->log("4"); $proxy->log({ prefix => 'D: ' }, "5"); are_events("log with proxy with prefix", [ 'A: B: C: 4', 'A: B: C: D: 5', ]); $logger->clear_prefix; $proxy->log("4"); $proxy->log({ prefix => 'D: ' }, "5"); are_events("remove the logger's parent's prefix", [ 'B: C: 4', 'B: C: D: 5', ]); $logger->set_prefix('A: '); my $proxprox = $proxy->proxy({ proxy_prefix => 'E: ', }); $proxprox->log("6"); $proxprox->set_prefix('F: '); $proxprox->log("7"); $proxprox->log({ prefix => 'G: ' }, "8"); are_events("second-order proxy, basic logging", [ 'A: B: C: E: 6', 'A: B: C: E: F: 7', 'A: B: C: E: F: G: 8', ]); $logger->log_debug("logger debug"); $proxy->log_debug("proxy debug"); $proxprox->log_debug("proxprox debug"); are_events("no debugging on at first", [ ]); $proxy->set_debug(1); $logger->log_debug("logger debug"); $proxy->log_debug("proxy debug"); $proxprox->log_debug("proxprox debug"); are_events("debugging in middle tier (middle set_debug)", [ 'A: B: C: proxy debug', 'A: B: C: E: F: proxprox debug', ]); $proxprox->set_debug(0); $logger->log_debug("logger debug"); $proxy->log_debug("proxy debug"); $proxprox->log_debug("proxprox debug"); are_events("debugging in middle tier", [ 'A: B: C: proxy debug', ]); sub unmute_all { $_->clear_muted for ($proxy, $proxprox); $logger->unmute; }; unmute_all; $proxprox->mute; $proxprox->log("proxprox"); $proxy->log("proxy"); $logger->log("logger"); are_events("only muted proxprox", [ 'A: B: C: proxy', 'A: logger', ]); unmute_all; $proxy->mute; $proxprox->log("proxprox"); $proxy->log("proxy"); $logger->log("logger"); are_events("muted proxy", [ 'A: logger', ]); unmute_all; $proxprox->unmute; $proxy->mute; $proxprox->log("proxprox"); $proxy->log("proxy"); $logger->log("logger"); are_events("muted proxy, unmuted proxprox", [ 'A: logger', ]); ok($logger->logger == $logger, "logger->logger == logger"); ok($proxy->logger == $logger, "proxy->logger == logger"); ok($proxprox->logger == $logger, "proxprox->logger == logger"); ok($logger->parent == $logger, "logger->parent == logger"); ok($proxy->parent == $logger, "proxy->parent == logger"); ok($proxprox->parent == $proxy, "proxprox->parent == proxy"); done_testing; META.json100644000766000024 3341012264314006 15641 0ustar00rjbsstaff000000000000Log-Dispatchouli-2.009{ "abstract" : "a simple wrapper around Log::Dispatch", "author" : [ "Ricardo SIGNES " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 5.010, CPAN::Meta::Converter version 2.133380", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Log-Dispatchouli", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "6.30" } }, "develop" : { "requires" : { "Test::Pod" : "1.41", "version" : "0.9901" } }, "runtime" : { "requires" : { "Carp" : "0", "File::Spec" : "0", "Log::Dispatch" : "0", "Log::Dispatch::Array" : "0", "Log::Dispatch::File" : "0", "Log::Dispatch::Screen" : "0", "Log::Dispatch::Syslog" : "0", "Params::Util" : "0", "Scalar::Util" : "0", "String::Flogger" : "0", "Sub::Exporter" : "0", "Sub::Exporter::GlobExporter" : "0.002", "Sys::Syslog" : "0.16", "Try::Tiny" : "0.04", "overload" : "0", "strict" : "0", "warnings" : "0" } }, "test" : { "requires" : { "File::Spec::Functions" : "0", "File::Temp" : "0", "Test::Deep" : "0", "Test::Fatal" : "0", "Test::More" : "0.96", "base" : "0", "lib" : "0" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/rjbs/Log-Dispatchouli/issues" }, "homepage" : "https://github.com/rjbs/Log-Dispatchouli", "repository" : { "type" : "git", "url" : "https://github.com/rjbs/Log-Dispatchouli.git", "web" : "https://github.com/rjbs/Log-Dispatchouli" } }, "version" : "2.009", "x_Dist_Zilla" : { "perl" : { "version" : "5.018002" }, "plugins" : [ { "class" : "Dist::Zilla::Plugin::Git::GatherDir", "name" : "@RJBS/Git::GatherDir", "version" : "2.019" }, { "class" : "Dist::Zilla::Plugin::CheckPrereqsIndexed", "name" : "@RJBS/CheckPrereqsIndexed", "version" : "0.010" }, { "class" : "Dist::Zilla::Plugin::CheckExtraTests", "name" : "@RJBS/CheckExtraTests", "version" : "0.016" }, { "class" : "Dist::Zilla::Plugin::PromptIfStale", "config" : { "Dist::Zilla::Plugin::PromptIfStale" : { "check_all_plugins" : 0, "check_all_prereqs" : 0, "modules" : [ "Dist::Zilla::PluginBundle::RJBS" ], "phase" : "build", "skip" : [] } }, "name" : "@RJBS/RJBS-Outdated", "version" : "0.015" }, { "class" : "Dist::Zilla::Plugin::PromptIfStale", "config" : { "Dist::Zilla::Plugin::PromptIfStale" : { "check_all_plugins" : "1", "check_all_prereqs" : 0, "modules" : [], "phase" : "release", "skip" : [] } }, "name" : "@RJBS/CPAN-Outdated", "version" : "0.015" }, { "class" : "Dist::Zilla::Plugin::PruneCruft", "name" : "@RJBS/@Filter/PruneCruft", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::ManifestSkip", "name" : "@RJBS/@Filter/ManifestSkip", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::MetaYAML", "name" : "@RJBS/@Filter/MetaYAML", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::License", "name" : "@RJBS/@Filter/License", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::Readme", "name" : "@RJBS/@Filter/Readme", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::ExecDir", "name" : "@RJBS/@Filter/ExecDir", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::ShareDir", "name" : "@RJBS/@Filter/ShareDir", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::MakeMaker", "name" : "@RJBS/@Filter/MakeMaker", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::Manifest", "name" : "@RJBS/@Filter/Manifest", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::TestRelease", "name" : "@RJBS/@Filter/TestRelease", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::ConfirmRelease", "name" : "@RJBS/@Filter/ConfirmRelease", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::UploadToCPAN", "name" : "@RJBS/@Filter/UploadToCPAN", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::AutoPrereqs", "name" : "@RJBS/AutoPrereqs", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::Git::NextVersion", "name" : "@RJBS/Git::NextVersion", "version" : "2.019" }, { "class" : "Dist::Zilla::Plugin::PkgVersion", "name" : "@RJBS/PkgVersion", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::MetaConfig", "name" : "@RJBS/MetaConfig", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::MetaJSON", "name" : "@RJBS/MetaJSON", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::NextRelease", "name" : "@RJBS/NextRelease", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::Test::ChangesHasContent", "name" : "@RJBS/Test::ChangesHasContent", "version" : "0.006" }, { "class" : "Dist::Zilla::Plugin::PodSyntaxTests", "name" : "@RJBS/PodSyntaxTests", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::ReportVersions::Tiny", "name" : "@RJBS/ReportVersions::Tiny", "version" : "1.10" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "test", "type" : "requires" } }, "name" : "@RJBS/TestMoreWithSubtests", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::PodWeaver", "config" : { "Dist::Zilla::Plugin::PodWeaver" : { "config_plugins" : [ "@RJBS" ], "finder" : [ ":InstallModules", ":ExecFiles" ], "plugins" : [ { "class" : "Pod::Weaver::Plugin::EnsurePod5", "name" : "@CorePrep/EnsurePod5", "version" : "4.006" }, { "class" : "Pod::Weaver::Plugin::H1Nester", "name" : "@CorePrep/H1Nester", "version" : "4.006" }, { "class" : "Pod::Weaver::Plugin::SingleEncoding", "name" : "@RJBS/SingleEncoding", "version" : "4.006" }, { "class" : "Pod::Weaver::Section::Name", "name" : "@RJBS/Name", "version" : "4.006" }, { "class" : "Pod::Weaver::Section::Version", "name" : "@RJBS/Version", "version" : "4.006" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@RJBS/Prelude", "version" : "4.006" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@RJBS/Synopsis", "version" : "4.006" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@RJBS/Description", "version" : "4.006" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@RJBS/Overview", "version" : "4.006" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@RJBS/Stability", "version" : "4.006" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "Attributes", "version" : "4.006" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "Methods", "version" : "4.006" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "Functions", "version" : "4.006" }, { "class" : "Pod::Weaver::Section::Leftovers", "name" : "@RJBS/Leftovers", "version" : "4.006" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@RJBS/postlude", "version" : "4.006" }, { "class" : "Pod::Weaver::Section::Authors", "name" : "@RJBS/Authors", "version" : "4.006" }, { "class" : "Pod::Weaver::Section::Legal", "name" : "@RJBS/Legal", "version" : "4.006" }, { "class" : "Pod::Weaver::Plugin::Transformer", "name" : "@RJBS/List", "version" : "4.006" } ] } }, "name" : "@RJBS/PodWeaver", "version" : "4.005" }, { "class" : "Dist::Zilla::Plugin::GithubMeta", "name" : "@RJBS/GithubMeta", "version" : "0.42" }, { "class" : "Dist::Zilla::Plugin::Git::Check", "name" : "@RJBS/@Git/Check", "version" : "2.019" }, { "class" : "Dist::Zilla::Plugin::Git::Commit", "name" : "@RJBS/@Git/Commit", "version" : "2.019" }, { "class" : "Dist::Zilla::Plugin::Git::Tag", "name" : "@RJBS/@Git/Tag", "version" : "2.019" }, { "class" : "Dist::Zilla::Plugin::Git::Push", "name" : "@RJBS/@Git/Push", "version" : "2.019" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "runtime", "type" : "requires" } }, "name" : "Prereqs", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":InstallModules", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":IncModules", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":TestFiles", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExecFiles", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ShareFiles", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":MainModule", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":AllFiles", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":NoFiles", "version" : "5.010" } ], "zilla" : { "class" : "Dist::Zilla::Dist::Builder", "config" : { "is_trial" : "0" }, "version" : "5.010" } } } global.t100644000766000024 176212264314006 16075 0ustar00rjbsstaff000000000000Log-Dispatchouli-2.009/tuse strict; use warnings; use Test::Fatal; use Test::More; use Log::Dispatchouli::Global '$Logger' => { init => { ident => 't/global.t', log_pid => 0, to_self => 1, }}; { package Alpha; use Log::Dispatchouli::Global '$Logger'; sub call_bravo { my ($self, $n) = @_; local $Logger = $Logger->proxy({ proxy_prefix => "$n: " }); $Logger->log("inside call_bravo"); Bravo->endpoint; } } { package Bravo; use Log::Dispatchouli::Global '$Logger' => { -as => 'L' }; sub endpoint { my ($self, $n) = @_; $L->log("inside Bravo::endpoint"); } } isa_ok($Logger, 'Log::Dispatchouli', 'imported $Logger'); $Logger->log("first"); Alpha->call_bravo(123); $Logger->log("last"); my $events = $Logger->events; is($events->[0]->{message}, 'first', '1st log'); is($events->[1]->{message}, '123: inside call_bravo', '2nd log'); is($events->[2]->{message}, '123: inside Bravo::endpoint', '3rd log'); is($events->[3]->{message}, 'last', '4th log'); done_testing; Makefile.PL100644000766000024 421712264314006 16155 0ustar00rjbsstaff000000000000Log-Dispatchouli-2.009 # This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.010. use strict; use warnings; use ExtUtils::MakeMaker 6.30; my %WriteMakefileArgs = ( "ABSTRACT" => "a simple wrapper around Log::Dispatch", "AUTHOR" => "Ricardo SIGNES ", "BUILD_REQUIRES" => {}, "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => "6.30" }, "DISTNAME" => "Log-Dispatchouli", "EXE_FILES" => [], "LICENSE" => "perl", "NAME" => "Log::Dispatchouli", "PREREQ_PM" => { "Carp" => 0, "File::Spec" => 0, "Log::Dispatch" => 0, "Log::Dispatch::Array" => 0, "Log::Dispatch::File" => 0, "Log::Dispatch::Screen" => 0, "Log::Dispatch::Syslog" => 0, "Params::Util" => 0, "Scalar::Util" => 0, "String::Flogger" => 0, "Sub::Exporter" => 0, "Sub::Exporter::GlobExporter" => "0.002", "Sys::Syslog" => "0.16", "Try::Tiny" => "0.04", "overload" => 0, "strict" => 0, "warnings" => 0 }, "TEST_REQUIRES" => { "File::Spec::Functions" => 0, "File::Temp" => 0, "Test::Deep" => 0, "Test::Fatal" => 0, "Test::More" => "0.96", "base" => 0, "lib" => 0 }, "VERSION" => "2.009", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "Carp" => 0, "File::Spec" => 0, "File::Spec::Functions" => 0, "File::Temp" => 0, "Log::Dispatch" => 0, "Log::Dispatch::Array" => 0, "Log::Dispatch::File" => 0, "Log::Dispatch::Screen" => 0, "Log::Dispatch::Syslog" => 0, "Params::Util" => 0, "Scalar::Util" => 0, "String::Flogger" => 0, "Sub::Exporter" => 0, "Sub::Exporter::GlobExporter" => "0.002", "Sys::Syslog" => "0.16", "Test::Deep" => 0, "Test::Fatal" => 0, "Test::More" => "0.96", "Try::Tiny" => "0.04", "base" => 0, "lib" => 0, "overload" => 0, "strict" => 0, "warnings" => 0 ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); env-value.t100644000766000024 173312264314006 16535 0ustar00rjbsstaff000000000000Log-Dispatchouli-2.009/t#!perl use strict; use warnings; use Test::More; use Log::Dispatchouli; { package Xyzzy::Logger; use base 'Log::Dispatchouli'; sub env_prefix { 'XYZZY' } } { local $ENV{DISPATCHOULI_DEBUG} = 1; local $ENV{XYZZY_DEBUG} = 0; my $d_logger = Log::Dispatchouli->new_tester; my $x_logger = Xyzzy::Logger->new_tester; ok( $d_logger->is_debug, "DISPATCHOULI_ affects L::D logger"); ok( ! $x_logger->is_debug, "...but XYZZY_ overrides for X::L"); } { local $ENV{DISPATCHOULI_DEBUG} = 1; my $d_logger = Log::Dispatchouli->new_tester; my $x_logger = Xyzzy::Logger->new_tester; ok( $d_logger->is_debug, "DISPATCHOULI_ affects L::D logger"); ok( $x_logger->is_debug, "...and X::L will use it with no XYZZY_"); } { local $ENV{XYZZY_DEBUG} = 1; my $d_logger = Log::Dispatchouli->new_tester; my $x_logger = Xyzzy::Logger->new_tester; ok( $x_logger->is_debug, "XYZZY_ affects X::L"); ok( ! $d_logger->is_debug, "...but not L::D"); } done_testing; DDR000755000766000024 012264314006 15461 5ustar00rjbsstaff000000000000Log-Dispatchouli-2.009/t/libChild.pm100644000766000024 24612264314006 17164 0ustar00rjbsstaff000000000000Log-Dispatchouli-2.009/t/lib/DDRuse strict; package DDR::Child; use base 'DDR::Parent'; sub default_logger_args { return { ident => __PACKAGE__, log_pid => 0, to_self => 1, } } 1; SDR000755000766000024 012264314006 15500 5ustar00rjbsstaff000000000000Log-Dispatchouli-2.009/t/libChild.pm100644000766000024 24612264314006 17203 0ustar00rjbsstaff000000000000Log-Dispatchouli-2.009/t/lib/SDRuse strict; package SDR::Child; use base 'SDR::Parent'; sub default_logger_args { return { ident => __PACKAGE__, log_pid => 0, to_self => 1, } } 1; global-subclass.t100644000766000024 204612264314006 17706 0ustar00rjbsstaff000000000000Log-Dispatchouli-2.009/tuse strict; use warnings; use Test::More; use Scalar::Util qw(refaddr); use lib 't/lib'; # DDR - default default ref -- uses the default default_logger_ref { package DDR_P; use DDR::Parent '$Logger'; } { package DDR_C; use DDR::Child '$Logger'; } # SDR - shared default ref -- uses a default_logger_ref shared between classes { package SDR_P; use SDR::Parent '$Logger'; } { package SDR_C; use SDR::Child '$Logger'; } is( refaddr( $DDR_P::Logger ), refaddr( $DDR_C::Logger ), "DDR parent and child share logger storage", ); # DDR::Child can store its default in a different place, but # $DDR::Parent::Logger is already defined when we get here, so the logic is # "already defined and not equal to *my* default, so it is untouched." is($DDR_P::Logger->ident, 'DDR::Parent', "parent won the initialization race"); is( refaddr( $SDR_P::Logger ), refaddr( $SDR_C::Logger ), "SDR parent and child share logger storage", ); is( $SDR_P::Logger->ident, 'SDR::Parent', "SDR::Parent is initialized first, so its default wins", ); done_testing; Parent.pm100644000766000024 35112264314006 17367 0ustar00rjbsstaff000000000000Log-Dispatchouli-2.009/t/lib/DDRuse strict; package DDR::Parent; use base 'Log::Dispatchouli::Global'; sub logger_globref { no warnings 'once'; \*Logger } sub default_logger_args { return { ident => __PACKAGE__, log_pid => 0, to_self => 1, } } 1; Parent.pm100644000766000024 45212264314006 17410 0ustar00rjbsstaff000000000000Log-Dispatchouli-2.009/t/lib/SDRuse strict; package SDR::Parent; use base 'Log::Dispatchouli::Global'; sub logger_globref { no warnings 'once'; \*Logger } my $default_logger; sub default_logger_ref { \$default_logger } sub default_logger_args { return { ident => __PACKAGE__, log_pid => 0, to_self => 1, } } 1; Log000755000766000024 012264314006 15326 5ustar00rjbsstaff000000000000Log-Dispatchouli-2.009/libDispatchouli.pm100644000766000024 4215112264314006 20477 0ustar00rjbsstaff000000000000Log-Dispatchouli-2.009/lib/Loguse strict; use warnings; package Log::Dispatchouli; { $Log::Dispatchouli::VERSION = '2.009'; } # ABSTRACT: a simple wrapper around Log::Dispatch use Carp (); use File::Spec (); use Log::Dispatch; use Params::Util qw(_ARRAY0 _HASH0 _CODELIKE); use Scalar::Util qw(blessed weaken); use String::Flogger; use Try::Tiny 0.04; require Log::Dispatchouli::Proxy; our @CARP_NOT = qw(Log::Dispatchouli::Proxy); sub new { my ($class, $arg) = @_; my $ident = $arg->{ident} or Carp::croak "no ident specified when using $class"; my $config_id = defined $arg->{config_id} ? $arg->{config_id} : $ident; my %quiet_fatal; for ('quiet_fatal') { %quiet_fatal = map {; $_ => 1 } grep { defined } exists $arg->{$_} ? _ARRAY0($arg->{$_}) ? @{ $arg->{$_} } : $arg->{$_} : ('stderr'); }; my $pid_prefix = exists $arg->{log_pid} ? $arg->{log_pid} : 1; my $self = bless {} => $class; my $log = Log::Dispatch->new( callbacks => sub { return( ($pid_prefix ? "[$$] " : '') . {@_}->{message}) }, ); if ($arg->{to_file}) { require Log::Dispatch::File; my $log_file = File::Spec->catfile( ($arg->{log_path} || $self->env_value('PATH') || File::Spec->tmpdir), $arg->{log_file} || sprintf('%s.%04u%02u%02u', $ident, ((localtime)[5] + 1900), sprintf('%02d', (localtime)[4] + 1), sprintf('%02d', (localtime)[3]), ) ); $log->add( Log::Dispatch::File->new( name => 'logfile', min_level => 'debug', filename => $log_file, mode => 'append', callbacks => sub { # The time format returned here is subject to change. -- rjbs, # 2008-11-21 return (localtime) . ' ' . {@_}->{message} . "\n" } ) ); } if ($arg->{facility} and not $self->env_value('NOSYSLOG')) { require Log::Dispatch::Syslog; $log->add( Log::Dispatch::Syslog->new( name => 'syslog', min_level => 'debug', facility => $arg->{facility}, ident => $ident, logopt => 'pid', socket => 'native', callbacks => sub { my %arg = @_; my $message = $arg{message}; $message =~ s/\n//g; return $message; }, ), ); } if ($arg->{to_self}) { $self->{events} = []; require Log::Dispatch::Array; $log->add( Log::Dispatch::Array->new( name => 'self', min_level => 'debug', array => $self->{events}, ), ); } DEST: for my $dest (qw(err out)) { next DEST unless $arg->{"to_std$dest"}; require Log::Dispatch::Screen; $log->add( Log::Dispatch::Screen->new( name => "std$dest", min_level => 'debug', stderr => ($dest eq 'err' ? 1 : 0), callbacks => sub { my %arg = @_; "$arg{message}\n"; }, ($quiet_fatal{"std$dest"} ? (max_level => 'info') : ()), ), ); } $self->{dispatcher} = $log; $self->{prefix} = $arg->{prefix}; $self->{ident} = $ident; $self->{config_id} = $config_id; $self->{debug} = exists $arg->{debug} ? ($arg->{debug} ? 1 : 0) : ($self->env_value('DEBUG') ? 1 : 0); $self->{fail_fatal} = exists $arg->{fail_fatal} ? $arg->{fail_fatal} : 1; return $self; } sub _join { shift; join q{ }, @{ $_[0] } } sub log { my ($self, @rest) = @_; my $arg = _HASH0($rest[0]) ? shift(@rest) : {}; my $message; if ($arg->{fatal} or ! $self->get_muted) { try { my $flogger = $self->string_flogger; my @flogged = map {; $flogger->flog($_) } @rest; $message = @flogged > 1 ? $self->_join(\@flogged) : $flogged[0]; my $prefix = _ARRAY0($arg->{prefix}) ? [ @{ $arg->{prefix} } ] : [ $arg->{prefix} ]; for (reverse grep { defined } $self->get_prefix, @$prefix) { if (_CODELIKE( $_ )) { $message = $_->($message); } else { $message =~ s/^/$_/gm; } } $self->dispatcher->log( level => $arg->{level} || 'info', message => $message, ); } catch { $message = '(no message could be logged)' unless defined $message; die $_ if $self->{fail_fatal}; }; } Carp::croak $message if $arg->{fatal}; return; } sub log_fatal { my ($self, @rest) = @_; my $arg = _HASH0($rest[0]) ? shift(@rest) : {}; # for future expansion local $arg->{level} = defined $arg->{level} ? $arg->{level} : 'error'; local $arg->{fatal} = defined $arg->{fatal} ? $arg->{fatal} : 1; $self->log($arg, @rest); } sub log_debug { my ($self, @rest) = @_; return unless $self->is_debug; my $arg = _HASH0($rest[0]) ? shift(@rest) : {}; # for future expansion local $arg->{level} = defined $arg->{level} ? $arg->{level} : 'debug'; $self->log($arg, @rest); } sub set_debug { return($_[0]->{debug} = $_[1] ? 1 : 0); } sub get_debug { return $_[0]->{debug} } sub clear_debug { } sub mute { $_[0]{muted} = 1 } sub unmute { $_[0]{muted} = 0 } sub set_muted { return($_[0]->{muted} = $_[1] ? 1 : 0); } sub get_muted { return $_[0]->{muted} } sub clear_muted { } sub get_prefix { return $_[0]->{prefix} } sub set_prefix { $_[0]->{prefix} = $_[1] } sub clear_prefix { $_[0]->unset_prefix } sub unset_prefix { undef $_[0]->{prefix} } sub ident { $_[0]{ident} } sub config_id { $_[0]{config_id} } sub string_flogger { 'String::Flogger' } sub env_prefix { return; } sub env_value { my ($self, $suffix) = @_; my @path = grep { defined } ($self->env_prefix, 'DISPATCHOULI'); for my $prefix (@path) { my $name = join q{_}, $prefix, $suffix; return $ENV{ $name } if defined $ENV{ $name }; } return; } sub new_tester { my ($class, $arg) = @_; $arg ||= {}; return $class->new({ ident => "$$:$0", log_pid => 0, %$arg, to_stderr => 0, to_stdout => 0, to_file => 0, to_self => 1, facility => undef, }); } sub events { Carp::confess "->events called on a logger not logging to self" unless $_[0]->{events}; return $_[0]->{events}; } sub clear_events { Carp::confess "->events called on a logger not logging to self" unless $_[0]->{events}; @{ $_[0]->{events} } = (); return; } sub proxy { my ($self, $arg) = @_; $arg ||= {}; require Log::Dispatchouli::Proxy; Log::Dispatchouli::Proxy->_new({ parent => $self, logger => $self, proxy_prefix => $arg->{proxy_prefix}, (exists $arg->{debug} ? (debug => ($arg->{debug} ? 1 : 0)) : ()), }); } sub parent { $_[0] } sub logger { $_[0] } sub dispatcher { $_[0]->{dispatcher} } sub is_debug { $_[0]->get_debug } sub is_info { 1 } sub is_fatal { 1 } sub info { shift()->log(@_); } sub fatal { shift()->log_fatal(@_); } sub debug { shift()->log_debug(@_); } use overload '&{}' => sub { my ($self) = @_; sub { $self->log(@_) } }, fallback => 1, ; 1; __END__ =pod =encoding UTF-8 =head1 NAME Log::Dispatchouli - a simple wrapper around Log::Dispatch =head1 VERSION version 2.009 =head1 SYNOPSIS my $logger = Log::Dispatchouli->new({ ident => 'stuff-purger', facility => 'daemon', to_stdout => $opt->{print}, debug => $opt->{verbose} }); $logger->log([ "There are %s items left to purge...", $stuff_left ]); $logger->log_debug("this is extra often-ignored debugging log"); $logger->log_fatal("Now we will die!!"); =head1 DESCRIPTION Log::Dispatchouli is a thin layer above L and meant to make it dead simple to add logging to a program without having to think much about categories, facilities, levels, or things like that. It is meant to make logging just configurable enough that you can find the logs you want and just easy enough that you will actually log things. Log::Dispatchouli can log to syslog (if you specify a facility), standard error or standard output, to a file, or to an array in memory. That last one is mostly useful for testing. In addition to providing as simple a way to get a handle for logging operations, Log::Dispatchouli uses L to process the things to be logged, meaning you can easily log data structures. Basically: strings are logged as is, arrayrefs are taken as (sprintf format, args), and subroutines are called only if needed. For more information read the L docs. =head1 METHODS =head2 new my $logger = Log::Dispatchouli->new(\%arg); This returns a new logger, a Log::Dispatchouli object. Valid arguments are: ident - the name of the thing logging (mandatory) to_self - log to the logger object for testing; default: false to_stdout - log to STDOUT; default: false to_stderr - log to STDERR; default: false facility - to which syslog facility to send logs; default: none to_file - log to PROGRAM_NAME.YYYYMMDD in the log path; default: false log_file - a leaf name for the file to log to with to_file log_path - path in which to log to file; defaults to DISPATCHOULI_PATH environment variable or, failing that, to your system's tmpdir log_pid - if true, prefix all log entries with the pid; default: true fail_fatal - a boolean; if true, failure to log is fatal; default: true muted - a boolean; if true, only fatals are logged; default: false debug - a boolean; if true, log_debug method is not a no-op defaults to the truth of the DISPATCHOULI_DEBUG env var quiet_fatal - 'stderr' or 'stdout' or an arrayref of zero, one, or both fatal log messages will not be logged to these (default: stderr) config_id - a name for this logger's config; rarely needed! The log path is either F or the value of the F env var. If the F env var is true, we don't log to syslog. =head2 log $logger->log(@messages); $logger->log(\%arg, @messages); This method uses L on the input, then logs the result. Each message is flogged individually, then joined with spaces. If the first argument is a hashref, it will be used as extra arguments to logging. It may include a C entry to preprocess the message by prepending a string (if the prefix is a string) or calling a subroutine to generate a new message (if the prefix is a coderef). =head2 log_fatal This behaves like the C method, but will throw the logged string as an exception after logging. This method can also be called as C, to match other popular logging interfaces. B and not C>. =head2 log_debug This behaves like the C method, but will only log (at the debug level) if the logger object has its debug property set to true. This method can also be called as C, to match other popular logging interfaces. B and not C>. =head2 set_debug $logger->set_debug($bool); This sets the logger's debug property, which affects the behavior of C. =head2 get_debug This gets the logger's debug property, which affects the behavior of C. =head2 clear_debug This method does nothing, and is only useful for L objects. See L, below. =head2 set_muted $logger->set_muted($bool); This sets the logger's muted property, which affects the behavior of C. =head2 get_muted This gets the logger's muted property, which affects the behavior of C. =head2 clear_muted This method does nothing, and is only useful for L objects. See L, below. =head2 get_prefix my $prefix = $logger->get_prefix; This method returns the currently-set prefix for the logger, which may be a string or code reference or undef. See L. =head2 set_prefix $logger->set_prefix( $new_prefix ); This method changes the prefix. See L. =head2 clear_prefix This method clears any set logger prefix. (It can also be called as C, but this is deprecated. See L. =head2 ident This method returns the logger's ident. =head2 config_id This method returns the logger's configuration id, which defaults to its ident. This can be used to make two loggers equivalent in Log::Dispatchouli::Global so that trying to reinitialize with a new logger with the same C as the current logger will not throw an exception, and will simply do no thing. =head2 dispatcher This returns the underlying Log::Dispatch object. This is not the method you're looking for. Move along. =head1 LOGGER PREFIX Log messages may be prepended with information to set context. This can be set at a logger level or per log item. The simplest example is: my $logger = Log::Dispatchouli->new( ... ); $logger->set_prefix("Batch 123: "); $logger->log("begun processing"); # ... $logger->log("finished processing"); The above will log something like: Batch 123: begun processing Batch 123: finished processing To pass a prefix per-message: $logger->log({ prefix => 'Sub-Item 234: ' }, 'error!') # Logs: Batch 123: Sub-Item 234: error! If the prefix is a string, it is prepended to each line of the message. If it is a coderef, it is called and passed the message to be logged. The return value is logged instead. L also have their own prefix settings, which accumulate. So: my $proxy = $logger->proxy({ proxy_prefix => 'Subsystem 12: ' }); $proxy->set_prefix('Page 9: '); $proxy->log({ prefix => 'Paragraph 6: ' }, 'Done.'); ...will log... Batch 123: Subsystem 12: Page 9: Paragraph 6: Done. =head1 METHODS FOR SUBCLASSING =head2 string_flogger This method returns the thing on which F will be called to format log messages. By default, it just returns C =head2 env_prefix This method should return a string used as a prefix to find environment variables that affect the logger's behavior. For example, if this method returns C then when checking the environment for a default value for the C parameter, Log::Dispatchouli will first check C, then C. By default, this method returns C<()>, which means no extra environment variable is checked. =head2 env_value my $value = $logger->env_value('DEBUG'); This method returns the value for the environment variable suffix given. For example, the example given, calling with C will check C. =head1 METHODS FOR TESTING =head2 new_tester my $logger = Log::Dispatchouli->new_tester( \%arg ); This returns a new logger that logs only C. It's useful in testing. If no C arg is provided, one will be generated. C is off by default, but can be overridden. C<\%arg> is optional. =head2 events This method returns the arrayref of events logged to an array in memory (in the logger). If the logger is not logging C this raises an exception. =head2 clear_events This method empties the current sequence of events logged into an array in memory. If the logger is not logging C this raises an exception. =head1 METHODS FOR PROXY LOGGERS =head2 proxy my $proxy_logger = $logger->proxy( \%arg ); This method returns a new proxy logger -- an instance of L -- which will log through the given logger, but which may have some settings localized. C<%arg> is optional. It may contain the following entries: =over 4 =item proxy_prefix This is a prefix that will be applied to anything the proxy logger logs, and cannot be changed. =item debug This can be set to true or false to change the proxy's "am I in debug mode?" setting. It can be changed or cleared later on the proxy. =back =head2 parent =head2 logger These methods return the logger itself. (They're more useful when called on proxy loggers.) =head1 METHODS FOR API COMPATIBILITY To provide compatibility with some other loggers, most specifically L, the following methods are provided. You should not use these methods without a good reason, and you should never subclass them. Instead, subclass the methods they call. =over 4 =item is_debug This method calls C. =item is_info =item is_fatal These methods return true. =item info =item fatal =item debug These methods redispatch to C, C, and C respectively. =back =head1 SEE ALSO =over 4 =item * L =item * L =back =head1 AUTHOR Ricardo SIGNES =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2014 by Ricardo SIGNES. 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 release000755000766000024 012264314006 16112 5ustar00rjbsstaff000000000000Log-Dispatchouli-2.009/xtpod-syntax.t100644000766000024 33212264314006 20523 0ustar00rjbsstaff000000000000Log-Dispatchouli-2.009/xt/release#!perl # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use Test::More; eval "use Test::Pod 1.41"; plan skip_all => "Test::Pod 1.41 required for testing POD" if $@; all_pod_files_ok(); 000-report-versions-tiny.t100644000766000024 613212264314006 21270 0ustar00rjbsstaff000000000000Log-Dispatchouli-2.009/tuse strict; use warnings; use Test::More 0.88; # This is a relatively nice way to avoid Test::NoWarnings breaking our # expectations by adding extra tests, without using no_plan. It also helps # avoid any other test module that feels introducing random tests, or even # test plans, is a nice idea. our $success = 0; END { $success && done_testing; } # List our own version used to generate this my $v = "\nGenerated by Dist::Zilla::Plugin::ReportVersions::Tiny v1.10\n"; eval { # no excuses! # report our Perl details my $want = "any version"; $v .= "perl: $] (wanted $want) on $^O from $^X\n\n"; }; defined($@) and diag("$@"); # Now, our module version dependencies: sub pmver { my ($module, $wanted) = @_; $wanted = " (want $wanted)"; my $pmver; eval "require $module;"; if ($@) { if ($@ =~ m/Can't locate .* in \@INC/) { $pmver = 'module not found.'; } else { diag("${module}: $@"); $pmver = 'died during require.'; } } else { my $version; eval { $version = $module->VERSION; }; if ($@) { diag("${module}: $@"); $pmver = 'died during VERSION check.'; } elsif (defined $version) { $pmver = "$version"; } else { $pmver = ''; } } # So, we should be good, right? return sprintf('%-45s => %-10s%-15s%s', $module, $pmver, $wanted, "\n"); } eval { $v .= pmver('Carp','any version') }; eval { $v .= pmver('ExtUtils::MakeMaker','6.30') }; eval { $v .= pmver('File::Spec','any version') }; eval { $v .= pmver('File::Spec::Functions','any version') }; eval { $v .= pmver('File::Temp','any version') }; eval { $v .= pmver('Log::Dispatch','any version') }; eval { $v .= pmver('Log::Dispatch::Array','any version') }; eval { $v .= pmver('Log::Dispatch::File','any version') }; eval { $v .= pmver('Log::Dispatch::Screen','any version') }; eval { $v .= pmver('Log::Dispatch::Syslog','any version') }; eval { $v .= pmver('Params::Util','any version') }; eval { $v .= pmver('Scalar::Util','any version') }; eval { $v .= pmver('String::Flogger','any version') }; eval { $v .= pmver('Sub::Exporter','any version') }; eval { $v .= pmver('Sub::Exporter::GlobExporter','0.002') }; eval { $v .= pmver('Sys::Syslog','0.16') }; eval { $v .= pmver('Test::Deep','any version') }; eval { $v .= pmver('Test::Fatal','any version') }; eval { $v .= pmver('Test::More','0.96') }; eval { $v .= pmver('Try::Tiny','0.04') }; eval { $v .= pmver('base','any version') }; eval { $v .= pmver('lib','any version') }; eval { $v .= pmver('overload','any version') }; eval { $v .= pmver('strict','any version') }; eval { $v .= pmver('warnings','any version') }; # All done. $v .= <<'EOT'; Thanks for using my code. I hope it works for you. If not, please try and include this output in the bug report. That will help me reproduce the issue and solve your problem. EOT diag($v); ok(1, "we really didn't test anything, just reporting data"); $success = 1; # Work around another nasty module on CPAN. :/ no warnings 'once'; $Template::Test::NO_FLUSH = 1; exit 0; Dispatchouli000755000766000024 012264314006 17756 5ustar00rjbsstaff000000000000Log-Dispatchouli-2.009/lib/LogProxy.pm100644000766000024 700612264314006 21600 0ustar00rjbsstaff000000000000Log-Dispatchouli-2.009/lib/Log/Dispatchouliuse strict; use warnings; package Log::Dispatchouli::Proxy; { $Log::Dispatchouli::Proxy::VERSION = '2.009'; } # ABSTRACT: a simple wrapper around Log::Dispatch use Params::Util qw(_ARRAY0 _HASH0); sub _new { my ($class, $arg) = @_; my $guts = { parent => $arg->{parent}, logger => $arg->{logger}, debug => $arg->{debug}, proxy_prefix => $arg->{proxy_prefix}, }; bless $guts => $class; } sub proxy { my ($self, $arg) = @_; $arg ||= {}; (ref $self)->_new({ parent => $self, logger => $self->logger, debug => $arg->{debug}, muted => $arg->{muted}, proxy_prefix => $arg->{proxy_prefix}, }); } sub parent { $_[0]{parent} } sub logger { $_[0]{logger} } sub ident { $_[0]{logger}->ident } sub config_id { $_[0]{logger}->config_id } sub set_prefix { $_[0]{prefix} = $_[1] } sub get_prefix { $_[0]{prefix} } sub clear_prefix { undef $_[0]{prefix} } sub unset_prefix { $_[0]->clear_prefix } sub set_debug { $_[0]{debug} = $_[1] ? 1 : 0 } sub clear_debug { undef $_[0]{debug} } sub get_debug { return $_[0]{debug} if defined $_[0]{debug}; return $_[0]->parent->get_debug; } sub mute { $_[0]{muted} = 1 } sub unmute { $_[0]{muted} = 0 } sub set_muted { $_[0]{muted} = $_[1] ? 1 : 0 } sub clear_muted { undef $_[0]{muted} } sub _get_local_muted { $_[0]{muted} } sub get_muted { return $_[0]{muted} if defined $_[0]{muted}; return $_[0]->parent->get_muted; } sub _get_all_prefix { my ($self, $arg) = @_; return [ $self->{proxy_prefix}, $self->get_prefix, _ARRAY0($arg->{prefix}) ? @{ $arg->{prefix} } : $arg->{prefix} ]; } sub log { my ($self, @rest) = @_; my $arg = _HASH0($rest[0]) ? shift(@rest) : {}; return if $self->_get_local_muted and ! $arg->{fatal}; local $arg->{prefix} = $self->_get_all_prefix($arg); $self->parent->log($arg, @rest); } sub log_fatal { my ($self, @rest) = @_; my $arg = _HASH0($rest[0]) ? shift(@rest) : {}; local $arg->{fatal} = 1; $self->log($arg, @rest); } sub log_debug { my ($self, @rest) = @_; my $debug = $self->get_debug; return if defined $debug and ! $debug; my $arg = _HASH0($rest[0]) ? shift(@rest) : {}; local $arg->{level} = 'debug'; $self->log($arg, @rest); } sub info { shift()->log(@_); } sub fatal { shift()->log_fatal(@_); } sub debug { shift()->log_debug(@_); } 1; __END__ =pod =encoding UTF-8 =head1 NAME Log::Dispatchouli::Proxy - a simple wrapper around Log::Dispatch =head1 VERSION version 2.009 =head1 DESCRIPTION A Log::Dispatchouli::Proxy object is the child of a L logger (or another proxy) and relays log messages to its parent. It behaves almost identically to a Log::Dispatchouli logger, and you should refer there for more of its documentation. Here are the differences: =over 4 =item * You can't create a proxy with C<< ->new >>, only by calling C<< ->proxy >> on an existing logger or proxy. =item * C will set a value for the proxy; if none is set, C will check the parent's setting; C will clear any set value on this proxy =item * C messages will be redispatched to C (bug to the 'debug' logging level) to prevent parent loggers from dropping them due to C setting differences =back =head1 AUTHOR Ricardo SIGNES =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2014 by Ricardo SIGNES. 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 Global.pm100644000766000024 1770712264314006 21710 0ustar00rjbsstaff000000000000Log-Dispatchouli-2.009/lib/Log/Dispatchouliuse strict; use warnings; package Log::Dispatchouli::Global; { $Log::Dispatchouli::Global::VERSION = '2.009'; } # ABSTRACT: a system for sharing a global, dynamically-scoped logger use Carp (); use Log::Dispatchouli; use Scalar::Util (); use Sub::Exporter::GlobExporter 0.002 qw(glob_exporter); # pass-through args use Sub::Exporter -setup => { collectors => { '$Logger' => glob_exporter(Logger => \'_build_logger'), }, }; sub logger_globref { no warnings 'once'; \*Logger; } sub current_logger { my ($self) = @_; my $globref = $self->logger_globref; unless (defined $$$globref) { $$$globref = $self->default_logger; } return $$$globref; } sub default_logger { my ($self) = @_; my $ref = $self->default_logger_ref; $$ref ||= $self->default_logger_class->new( $self->default_logger_args ); } sub default_logger_class { 'Log::Dispatchouli' } sub default_logger_args { return { ident => "default/$0", facility => undef, } } my %default_logger_for_glob; sub default_logger_ref { my ($self) = @_; my $glob = $self->logger_globref; my $addr = Scalar::Util::refaddr($glob); return \$default_logger_for_glob{ $addr }; } sub _equiv { my ($self, $x, $y) = @_; return 1 if Scalar::Util::refaddr($x) == Scalar::Util::refaddr($y); return 1 if $x->config_id eq $y->config_id; return } sub _build_logger { my ($self, $arg) = @_; my $globref = $self->logger_globref; my $default = $self->default_logger; my $Logger = $$$globref; if ($arg and $arg->{init}) { my $new_logger = $self->default_logger_class->new($arg->{init}); if ($Logger and not( $self->_equiv($Logger, $new_logger) or $self->_equiv($Logger, $default) ) ) { # We already set up a logger, so we'll check that our new one is # equivalent to the old. If so, we'll keep the old, since it's good # enough. If not, we'll raise an exception: you can't configure the # logger twice, with different configurations, in one program! # -- rjbs, 2011-01-21 my $old = $Logger->config_id; my $new = $new_logger->config_id; Carp::confess(sprintf( "attempted to initialize %s logger twice; old config %s, new config %s", $self, $old, $new, )); } $$$globref = $new_logger; } else { $$$globref ||= $default; } return $globref; } 1; __END__ =pod =encoding UTF-8 =head1 NAME Log::Dispatchouli::Global - a system for sharing a global, dynamically-scoped logger =head1 VERSION version 2.009 =head1 DESCRIPTION B: This interface is still experimental. Log::Dispatchouli::Global is a framework for a global logger object. In your top-level programs that are actually executed, you'd add something like this: use Log::Dispatchouli::Global '$Logger' => { init => { ident => 'My::Daemon', facility => 'local2', to_stdout => 1, }, }; This will import a C<$Logger> into your program, and more importantly will initialize it with a new L object created by passing the value for the C parameter to Log::Dispatchouli's C method. Much of the rest of your program, across various libraries, can then just use this: use Log::Dispatchouli::Global '$Logger'; sub whatever { ... $Logger->log("about to do something"); local $Logger = $Logger->proxy({ proxy_prefix => "whatever: " }); for (@things) { $Logger->log([ "doing thing %s", $_ ]); ... } } This eliminates the need to pass around what is effectively a global, while still allowing it to be specialized within certain contexts of your program. B Although you I just use Log::Dispatchouli::Global as your shared logging library, you almost I want to write a subclass that will only be shared amongst your application's classes. Log::Dispatchouli::Global is meant to be subclassed and shared only within controlled systems. Remember, I. =head1 USING In general, you will either be using a Log::Dispatchouli::Global class to get a C<$Logger> or to initialize it (and then get C<$Logger>). These are both demonstrated above. Also, when importing C<$Logger> you may request it be imported under a different name: use Log::Dispatchouli::Global '$Logger' => { -as => 'L' }; $L->log( ... ); There is only one class method that you are likely to use: C. This provides the value of the shared logger from the caller's context, initializing it to a default if needed. Even this method is unlikely to be required frequently, but it I allow users to I C<$Logger> without importing it. =head1 SUBCLASSING Before using Log::Dispatchouli::Global in your application, you should subclass it. When you subclass it, you should provide the following methods: =head2 logger_globref This method should return a globref in which the shared logger will be stored. Subclasses will be in their own package, so barring any need for cleverness, every implementation of this method can look like the following: sub logger_globref { no warnings 'once'; return \*Logger } =head2 default_logger If no logger has been initialized, but something tries to log, it gets the default logger, created by calling this method. The default implementation calls C on the C with the result of C as the arguments. =head2 default_logger_class This returns the class on which C will be called when initializing a logger, either from the C argument when importing or the default logger. Its default value is Log::Dispatchouli. =head2 default_logger_args If no logger has been initialized, but something tries to log, it gets the default logger, created by calling C on the C and passing the results of calling this method. Its default return value creates a sink, so that anything logged without an initialized logger is lost. =head2 default_logger_ref This method returns a scalar reference in which the cached default value is stored for comparison. This is used when someone tries to C the global. When someone tries to initialize the global logger, and it's already set, then: =over 4 =item * if the current value is the same as the default, the new value is set =item * if the current value is I the same as the default, we die =back Since you want the default to be isolated to your application's logger, the default behavior is default loggers are associated with the glob reference to which the default might be assigned. It is unlikely that you will need to interact with this method. =head1 COOKBOOK =head2 Common Logger Recipes Say you often use the same configuration for one kind of program, like automated tests. You've already written your own subclass to get your own storage and defaults, maybe C. You can't just write a subclass with a different default, because if another class using the same global has set the global with I default, yours won't be honored. You don't just want this new value to be the default, you want it to be I logger. What you want to do in this case is to initialize your logger normally, then reexport it, like this: package MyApp::Logger::Test; use parent 'MyApp::Logger'; use MyApp::Logger '$Logger' => { init => { ident => "Tester($0)", to_self => 1, facility => undef, }, }; This will set up the logger and re-export it, and will properly die if anything else attempts to initialize the logger to something else. =head1 AUTHOR Ricardo SIGNES =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2014 by Ricardo SIGNES. 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 changes_has_content.t100644000766000024 201112264314006 22426 0ustar00rjbsstaff000000000000Log-Dispatchouli-2.009/xt/release#!perl use Test::More tests => 2; note 'Checking Changes'; my $changes_file = 'Changes'; my $newver = '2.009'; my $trial_token = '-TRIAL'; SKIP: { ok(-e $changes_file, "$changes_file file exists") or skip 'Changes is missing', 1; ok(_get_changes($newver), "$changes_file has content for $newver"); } done_testing; # _get_changes copied and adapted from Dist::Zilla::Plugin::Git::Commit # by Jerome Quelin sub _get_changes { my $newver = shift; # parse changelog to find commit message open(my $fh, '<', $changes_file) or die "cannot open $changes_file: $!"; my $changelog = join('', <$fh>); close $fh; my @content = grep { /^$newver(?:$trial_token)?(?:\s+|$)/ ... /^\S/ } # from newver to un-indented split /\n/, $changelog; shift @content; # drop the version line # drop unindented last line and trailing blank lines pop @content while ( @content && $content[-1] =~ /^(?:\S|\s*$)/ ); # return number of non-blank lines return scalar @content; }