NAME
Log::ger::Plugin::OptAway - Optimize away log statements
VERSION
version 0.009
SYNOPSIS
use Log::ger::Plugin->set('OptAway');
use Log::ger;
To demonstrate the effect of optimizing away:
% perl -MLog::ger -MO=Deparse -e'log_warn "foo\n"; log_debug "bar\n"'
log_warn("foo\n");
log_debug("bar\n");
-e syntax OK
% perl -MLog::ger::Plugin=OptAway -MLog::ger -MO=Deparse -e'log_warn "foo\n"; log_debug "bar\n"'
log_warn("foo\n");
'???';
-e syntax OK
To optimize away all levels:
use Log::ger::Plugin 'OptAway', all=>1;
DESCRIPTION
This plugin replaces logging statements that are higher than the current level ($Log::ger::Current_Level
) into a no-op statement using B::CallChecker magic at compile-time. The logging statements will become no-op and will have zero run-time overhead.
By default, since $Current_Level
is pre-set at 30 (warn) then log_info()
, log_debug()
, and log_trace()
calls will be turned into no-op.
If the configuration "all" is set to true, however, logger routines for all levels will be turned into no-op.
Caveats:
must be done at compile-time
only works when you are using procedural style
once optimized away, subsequent logger reinitialization at run-time won't take effect
CONFIGURATION
all
Boolean. If set to true, will optimize away all levels, including multi-level logger routines. This is an easy way to disable all logging.
By default, only levels above the current level ($Log::ger::Current_level
) will be optimized away.
SEE ALSO
AUTHOR
perlancar <perlancar@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2020, 2018, 2017 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.