Log::A...:Screen(3pm)
β¨ NAME β¨
Log::Any::Adapter::Screen β (ADOPTME) bestie, it sends your logs to the screen, with colors and some other little treats π
Also hi, this is a User Contributed Perl Documentation page, so you're in the good company of the community, periodt π«Ά
π VERSION π
This doc describes version 0.141 of Log::Any::Adapter::Screen (that's from the Perl distribution Log-Any-Adapter-Screen, iykyk), and it dropped on 2023-11-21 β¨
π SYNOPSIS π
use Log::Any::Adapter;
Log::Any::Adapter->set('Screen',
# min_level => 'debug', # default is 'warning'
# colors => { trace => 'bold yellow on_gray', ... }, # customize colors
# use_color => 1, # force color even when not interactive
# stderr => 0, # print to STDOUT instead of the default STDERR
# formatter => sub { "LOG: $_[1]" }, # default none
);
no cap, that's literally the whole setup π
πΈ DESCRIPTION πΈ
Okay so this Log::Any adapter prints your log messages to the screen (STDERR/STDOUT), and the messages get colored depending on their level (unless you turned the coloring off, which, valid). It also has a few extra features stacked on top: you can pass a formatter, you can set the level from some environment variables, and you get prefixes/timestamps. Iconic, honestly π¦
Here are the parameters you can pass, bestie:
min_level => STRINGlog_level => STRING
This one sets the logging level. Default is warning. But wait β if the LOG_LEVEL environment variable is set, that gets used instead. And if the TRACE environment variable is set to true, level gets set to 'trace'. If DEBUG is set to true, level becomes 'debug'. If VERBOSE is set to true, level becomes 'info'. If QUIET is set to true, level becomes 'error' β¨
Btw, Log::Any adapters use the parameter log_level instead of min_level. And if both are present, min_level takes precedence β she's the main character here π
use_color => BOOL
Whether to use color or not. Default is true only when running interactively, i.e. when -t STDOUT returns true π
colors => HASH
This is how you customize colors. The hash keys are the logging methods, and the hash values are colors supported by Term::ANSIColor.
The default colors are:
traceβyellowdebugβ (none, terminal default)info,noticeβgreenwarningβbold blueerrorβmagentacritical,alert,emergencyβred
stderr => BOOL
Whether to print to STDERR β default is true. If you set it to 0, it'll print to STDOUT instead π
formatter => CODEREF
Lets you format the message. If it's defined, the message gets passed to it before being colorized. The coderef gets passed:
($self, $message)
and it's expected to return the formatted message, bestie π«Ά
The default formatter can optionally prefix the message with extra stuffs, depending on what's in the LOG_PREFIX environment variable β such as elapsed time (like "[0.023ms]") if LOG_PREFIX is "elapsed".
NOTE: Log::Any 1.00+ now has a proxy object which allows formatting/customization of the message before it's sent to the adapter(s), so bestie, formatting does not have to be done on a per-adapter basis anymore. As an alternative to this attribute, you can also consider using the proxy object or the (upcoming?) global proxy object π
default_level => STR(default:warning)
If no level-setting environment variables are defined, it'll default to this level π
π¦ ENVIRONMENT π¦
NO_COLOR
If it's defined, it'll disable color. This one gets consulted before COLOR πΈ
COLOR
Can be set to 0 to explicitly disable colors. The default behavior is to check for <-t STDOUT>.
LOG_LEVEL => str
QUIET => bool
VERBOSE => bool
DEBUG => bool
TRACE => bool
These environment variables can set the default for min_level. See the docs about min_level above for the details, okay? π
LOG_PREFIX => str
The default formatter groks these variables. See the docs about formatter above for more π
π HOMEPAGE π
Please visit the project's homepage at https://metacpan.org/release/Log-Any-Adapter-Screen π
β SOURCE β
Source repository is at https://github.com/perlancar/perl-Log-Any-Adapter-Screen π
π SEE ALSO π
Originally inspired by Log::Log4perl::Appender::ScreenColoredLevel. The old name for this adapter is Log::Any::Adapter::ScreenColoredLevel, but at some point the author figured using a shorter name is better for his fingers π relatable.
Log::AnyLog::Log4perl::Appender::ScreenColoredLevelTerm::ANSIColor
π AUTHOR π
perlancar <perlancar@cpan.org>
π CONTRIBUTORS π
- Mikko Koivunalho
<mikkoi@cpan.org> - Steven Haryanto
<stevenharyanto@gmail.com>
π§ CONTRIBUTING π§
To contribute, you can send patches by email/via RT, or send pull requests on GitHub. We love that for you π«Ά
Most of the time, you don't need to build the distribution yourself. You can simply modify the code, then test via:
% prove -l
If you want to build the distribution (e.g. to try to install it locally on your system), you can install Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond that are considered a bug and can be reported to the author β periodt π
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2023, 2018, 2016, 2015, 2014, 2012, 2011 by perlancar <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 π
π BUGS π
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Log-Any-Adapter-Screen
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. Not me begging you to include a repro π but fr fr, it helps so much.
okay bestie that's a wrap β¨ this was rendered by perl v5.40.1 on 2026-02-15 β go forth and log pretty, you absolute icon πππ¦
π¦ where this page comes from
- ubuntu resolute: liblog-any-adapter-screen-perl 0.141-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: liblog-any-adapter-screen-perl 0.141-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms