1Log::Any::IfLOG(3)    User Contributed Perl Documentation   Log::Any::IfLOG(3)
2
3
4

NAME

6       Log::Any::IfLOG - Load Log::Any only if "logging is enabled"
7

VERSION

9       This document describes version 0.090 of Log::Any::IfLOG (from Perl
10       distribution Log-Any-IfLOG), released on 2019-01-09.
11

SYNOPSIS

13        use Log::Any::IfLOG '$log';
14

DESCRIPTION

16       This module is a drop-in replacement/wrapper for Log::Any to be used
17       from your modules. This is a quick-hack solution to avoid the cost of
18       loading Log::Any under "normal condition". Since Log::Any 1.00, startup
19       overhead increases to about 7-10ms on my PC/laptop (from under 1ms for
20       the previous version). Because I want to keep startup overhead of CLI
21       apps under 50ms (see Perinci::CmdLine::Lite) to keep tab completion
22       from getting a noticeable lag, every millisecond counts.
23
24       This module will only load Log::Any when "logging is enabled".
25       Otherwise, it will just return without loading anything. If $log is
26       requested in import, a fake object is returned that responds to methods
27       like "debug", "is_debug" and so on but will do nothing when called and
28       just return 0.
29
30       To determine "logging is enabled":
31
32       •   Is $ENABLE_LOG defined?
33
34           This package variable can be used to force "logging enabled" (if
35           true) or "logging disabled" (if false). Normally, you don't need to
36           do this except for testing.
37
38       •   Is Log::Any is already loaded (from %INC)?
39
40           If Log::Any is already loaded, it means we have taken the overhead
41           hit anyway so logging is enabled.
42
43       •   Is one of log-related environment variables true?
44
45           If one of LOG, "TRACE", or "DEBUG", or "VERBOSE", or "QUIET", or
46           "LOG_LEVEL" is true then logging is enabled. These variables are
47           used by Perinci::CmdLine.
48
49           Otherwise, logging is disabled.
50

VARIABLES

52   $ENABLE_LOG => bool
53       This setting can be forced to force loading Log::Any or not.
54

ENVIRONMENT

56   LOG => bool
57   TRACE => bool
58   DEBUG => bool
59   VERBOSE => bool
60   QUIET => bool
61   LOG_LEVEL => str

HOMEPAGE

63       Please visit the project's homepage at
64       <https://metacpan.org/release/Log-Any-IfLOG>.
65

SOURCE

67       Source repository is at
68       <https://github.com/perlancar/perl-Log-Any-IfLOG>.
69

BUGS

71       Please report any bugs or feature requests on the bugtracker website
72       <https://rt.cpan.org/Public/Dist/Display.html?Name=Log-Any-IfLOG>
73
74       When submitting a bug or request, please include a test-file or a patch
75       to an existing test-file that illustrates the bug or desired feature.
76

SEE ALSO

78       Log::Any
79
80       <http://github.com/dagolden/Log-Any/issues/24>
81

AUTHOR

83       perlancar <perlancar@cpan.org>
84
86       This software is copyright (c) 2019, 2015 by perlancar@cpan.org.
87
88       This is free software; you can redistribute it and/or modify it under
89       the same terms as the Perl 5 programming language system itself.
90
91
92
93perl v5.32.1                      2021-01-27                Log::Any::IfLOG(3)
Impressum