Log::Any::IfLOG(3)
π Log::Any::IfLOG π
okay bestie, this is a page from the User Contributed Perl Documentation, and it's about Log::Any::IfLOG β a lil module with big "i refuse to pay for things i don't use" energy. let's get into it β¨
β¨ NAME β¨
Log::Any::IfLOG β load Log::Any only if "logging is enabled" π«Ά
πΈ VERSION πΈ
This doc describes version 0.090 of Log::Any::IfLOG (from the Perl distribution Log-Any-IfLOG), and it dropped on 2019-01-09. vintage. iconic. π
π SYNOPSIS π
use Log::Any::IfLOG '$log';
that's it. that's the whole vibe check. π
π¦ DESCRIPTION π¦
so this module is a drop-in replacement/wrapper for Log::Any that you use from your own modules. it's a quick-hack solution to dodge the cost of loading Log::Any under "normal condition", no cap.
here's the tea: since Log::Any 1.00, the startup overhead went up to about 7-10ms on the author's PC/laptop (it was under 1ms in the previous version π). and because he wants to keep startup overhead of CLI apps under 50ms (see Perinci::CmdLine::Lite) so that tab completion doesn't get a noticeable lag β literally every millisecond counts. every. single. one.
so the deal is: this module will only load Log::Any when "logging is enabled". otherwise it just returns without loading anything. and if $log is requested in import, you get back a fake object that responds to methods like debug, is_debug and so on, but does absolutely nothing when called and just returns 0. it's giving understudy who never gets called to stage. π
π how do we even know "logging is enabled"? π
here's the checklist, in order:
- Is
$ENABLE_LOGdefined? This package variable can be used to force "logging enabled" (if true) or "logging disabled" (if false). normally you don't need to do this except for testing. it's the manual override, bestie. - Is
Log::Anyalready loaded (from%INC)? IfLog::Anyis already loaded, it means we've taken the overhead hit anyway, so logging is enabled. no take-backsies. π₯ - Is one of log-related environment variables true? If one of
LOG,TRACE, orDEBUG, orVERBOSE, orQUIET, orLOG_LEVELis true, then logging is enabled. these variables are used byPerinci::CmdLine.
Otherwise, logging is disabled. that's the whole flowchart, periodt. β¨
π VARIABLES π
$ENABLE_LOG => bool
This setting can be forced to force loading Log::Any or not. you're the main character, you decide. π
π ENVIRONMENT π
LOG => boolTRACE => boolDEBUG => boolVERBOSE => boolQUIET => boolLOG_LEVEL => str
π HOMEPAGE π
Please visit the project's homepage at https://metacpan.org/release/Log-Any-IfLOG. go say hi. π«Ά
π§ SOURCE π§
Source repository is at https://github.com/perlancar/perl-Log-Any-IfLOG. it's right there, bestie, go read the code. β¨
β BUGS β
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. yes fr fr, receipts please, not just vibes. π
πΈ SEE ALSO πΈ
π AUTHOR π
perlancar <perlancar@cpan.org> β the moment. the legend. π
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2019, 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. slay, honestly. π β¨
and that's a wrap on Log::Any::IfLOG π this page came to you courtesy of perl v5.42.0, dated 2025-07-25 β mwah, take care of yourselves, and remember: only load what you need π¦π
π¦ where this page comes from
- fedora 43: perl-Log-Any-IfLOG 0.09.0-20.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms