Log::Any::IfLOG - Load Log::Any only if log-related environment variables are set
This document describes version 0.04 of Log::Any::IfLOG (from Perl distribution Log-Any-IfLOG), released on 2015-04-02.
use Log::Any::IfLOG '$log';
This module will load Log::Any only when LOG environment variable is true (or TRACE, or DEBUG, or VERBOSE, or QUIET, or LOG_LEVEL; these variables are used by Perinci::CmdLine). Otherwise, the module is not loaded and if user imports $log, a dumb object will be returned instead that will accept any method but return false.
LOG
TRACE
DEBUG
VERBOSE
QUIET
LOG_LEVEL
$log
This is a quick-hack solution to avoid the cost of loading Log::Any under "normal condition" (when log-enabling variables/flags are not set to true). Since Log::Any 1.00, startup overhead increases to about 7-10ms on my PC/laptop (from under 1ms for the previous version). Since I want to keep startup overhead of CLI apps under 50ms (see Perinci::CmdLine::Lite) to keep tab completion from getting a noticeable lag, every millisecond counts.
If set to true, will load Log::Any as usual. Otherwise, won't load Log::Any and will return a dumb object in $log instead.
These variables are used by Perinci::CmdLine as a shortcut to set log level. The setting of these variables indicate that user wants to see some logging, so Log::Any will be loaded under the presence of these variables.
Log::Any
http://github.com/dagolden/Log-Any/issues/24
Please visit the project's homepage at https://metacpan.org/release/Log-Any-IfLOG.
Source repository is at https://github.com/perlancar/perl-Log-Any-IfLOG.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Log-Any-IfLOG
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
perlancar <perlancar@cpan.org>
This software is copyright (c) 2015 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Log::Any::IfLOG, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Log::Any::IfLOG
CPAN shell
perl -MCPAN -e shell install Log::Any::IfLOG
For more information on module installation, please visit the detailed CPAN module installation guide.