.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "Log::Any::Adapter::Screen 3pm" .TH Log::Any::Adapter::Screen 3pm "2019-05-06" "perl v5.24.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Log::Any::Adapter::Screen \- Send logs to screen, with colors and some other features .SH "VERSION" .IX Header "VERSION" This document describes version 0.140 of Log::Any::Adapter::Screen (from Perl distribution Log-Any-Adapter-Screen), released on 2018\-12\-22. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 8 \& use Log::Any::Adapter; \& Log::Any::Adapter\->set(\*(AqScreen\*(Aq, \& # min_level => \*(Aqdebug\*(Aq, # default is \*(Aqwarning\*(Aq \& # colors => { trace => \*(Aqbold yellow on_gray\*(Aq, ... }, # 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 \& ); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This Log::Any adapter prints log messages to screen (\s-1STDERR/STDOUT\s0). The messages are colored according to level (unless coloring is turned off). It has a few other features: allow passing formatter, allow setting level from some environment variables, add prefix/timestamps. .PP Parameters: .IP "\(bu" 4 min_level => \s-1STRING\s0 .Sp Set logging level. Default is warning. If \s-1LOG_LEVEL\s0 environment variable is set, it will be used instead. If \s-1TRACE\s0 environment variable is set to true, level will be set to 'trace'. If \s-1DEBUG\s0 environment variable is set to true, level will be set to 'debug'. If \s-1VERBOSE\s0 environment variable is set to true, level will be set to 'info'.If \s-1QUIET\s0 environment variable is set to true, level will be set to \&'error'. .IP "\(bu" 4 use_color => \s-1BOOL\s0 .Sp Whether to use color or not. Default is true only when running interactively (\-t \&\s-1STDOUT\s0 returns true). .IP "\(bu" 4 colors => \s-1HASH\s0 .Sp Customize colors. Hash keys are the logging methods, hash values are colors supported by Term::ANSIColor. .Sp The default colors are: .Sp .Vb 8 \& method/level color \& \-\-\-\-\-\-\-\-\-\-\-\- \-\-\-\-\- \& trace yellow \& debug (none, terminal default) \& info, notice green \& warning bold blue \& error magenta \& critical, alert, emergency red .Ve .IP "\(bu" 4 stderr => \s-1BOOL\s0 .Sp Whether to print to \s-1STDERR,\s0 default is true. If set to 0, will print to \s-1STDOUT\s0 instead. .IP "\(bu" 4 formatter => \s-1CODEREF\s0 .Sp Allow formatting message. If defined, message will be passed before being colorized. Coderef will be passed: .Sp .Vb 1 \& ($self, $message) .Ve .Sp and is expected to return the formatted message. .Sp The default formatter can optionally prefix the message with extra stuffs, depending on the content of \s-1LOG_PREFIX\s0 environment variable, such as: elapsed time (e.g. \f(CW\*(C`[0.023ms]\*(C'\fR) if \s-1LOG_PREFIX\s0 is \f(CW\*(C`elapsed\*(C'\fR. .Sp \&\s-1NOTE:\s0 Log::Any 1.00+ now has a proxy object which allows formatting/customization of message before it is sent to adapter(s), so formatting does not have to be done on a per-adapter basis. As an alternative to this attribute, you can also consider using the proxy object or the (upcoming?) global proxy object. .IP "\(bu" 4 default_level => \s-1STR \s0(default: warning) .Sp If no level-setting environment variables are defined, will default to this level. .SH "ENVIRONMENT" .IX Header "ENVIRONMENT" .SS "\s-1NO_COLOR\s0" .IX Subsection "NO_COLOR" If defined, will disable color. Consulted before \*(L"\s-1COLOR\*(R"\s0. .SS "\s-1COLOR\s0" .IX Subsection "COLOR" Can be set to 0 to explicitly disable colors. The default is to check for \f(CW\*(C`<\-t STDOUT\*(C'\fR>. .SS "\s-1LOG_LEVEL\s0 => str" .IX Subsection "LOG_LEVEL => str" .SS "\s-1QUIET\s0 => bool" .IX Subsection "QUIET => bool" .SS "\s-1VERBOSE\s0 => bool" .IX Subsection "VERBOSE => bool" .SS "\s-1DEBUG\s0 => bool" .IX Subsection "DEBUG => bool" .SS "\s-1TRACE\s0 => bool" .IX Subsection "TRACE => bool" These environment variables can set the default for \f(CW\*(C`min_level\*(C'\fR. See documentation about \f(CW\*(C`min_level\*(C'\fR for more details. .SS "\s-1LOG_PREFIX\s0 => str" .IX Subsection "LOG_PREFIX => str" The default formatter groks these variables. See documentation about \&\f(CW\*(C`formatter\*(C'\fR about more details. .SH "HOMEPAGE" .IX Header "HOMEPAGE" Please visit the project's homepage at . .SH "SOURCE" .IX Header "SOURCE" Source repository is at . .SH "BUGS" .IX Header "BUGS" Please report any bugs or feature requests on the bugtracker website .PP 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. .SH "SEE ALSO" .IX Header "SEE ALSO" Originally inspired by Log::Log4perl::Appender::ScreenColoredLevel. The old name for this adapter is Log::Any::Adapter::ScreenColoredLevel but at some point I figure using a shorter name is better for my fingers. .PP Log::Any .PP Log::Log4perl::Appender::ScreenColoredLevel .PP Term::ANSIColor .SH "AUTHOR" .IX Header "AUTHOR" perlancar .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2018, 2016, 2015, 2014, 2012, 2011 by perlancar@cpan.org. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.