The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Log::ger::Manual::Tutorial::410_Output_Screen - More about the screen output

VERSION

version 0.032.003

OVERVIEW

The Screen output module outputs log messages to stderr by default. To use stdout instead, set the configuration parameter stderr to false.

COLORS

By default, log messages are colored according to its level. For example, my dear, fatals are red and warnings are blue.

Colors are not enabled when program runs non-interactively (tested using -t STDOUT). If you want to force enable color, set the configuration parameter use_color to true. To force disable color, set use_color to false. Alternatively, you can also use the COLOR environment variable, e.g.:

 % COLOR=1 yourapp.pl | less -R; # force enable color

If you want to customize the colors, currently you can modify the %Log::ger::Output::Screen::colors directly. For example say you want to change fatal to white on red:

 use Log::ger::Output 'Screen';
 use Log::ger::Util;
 use Log::ger;
 use Term::ANSIColor;

 $Log::ger::Output::Screen::colors{Log::ger::Util::numeric_level("fatal")} = color("white on_red");
 log_fatal("mayday!");

Another example, using Color::ANSI::Util and 256/24bit colors, say you want to change debug to #c0d1d5:

 use Log::ger::Output 'Screen';
 use Log::ger::Util;
 use Log::ger;
 use Color::ANSI::Util qw(ansibg ansifg);

 $Log::ger::Output::Screen::colors{Log::ger::Util::numeric_level("debug")} = ansifg("c0d1d5");
 Log::ger::Util::set_level("debug");
 log_debug("some debug information ...");

Also take a look at color scheme modules in Log::ger::Screen::ColorScheme::*.

FAQ

How to output to screen as well as file?

See 481_Output_Composite.

SEE ALSO

AUTHOR

perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2020, 2019, 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.