1Log::Any::Adapter::ScreUesne(r3)Contributed Perl DocumenLtoagt:i:oAnny::Adapter::Screen(3)
2
3
4

NAME

6       Log::Any::Adapter::Screen - Send logs to screen, with colors and some
7       other features
8

VERSION

10       This document describes version 0.140 of Log::Any::Adapter::Screen
11       (from Perl distribution Log-Any-Adapter-Screen), released on
12       2018-12-22.
13

SYNOPSIS

15        use Log::Any::Adapter;
16        Log::Any::Adapter->set('Screen',
17            # min_level => 'debug', # default is 'warning'
18            # colors    => { trace => 'bold yellow on_gray', ... }, # customize colors
19            # use_color => 1, # force color even when not interactive
20            # stderr    => 0, # print to STDOUT instead of the default STDERR
21            # formatter => sub { "LOG: $_[1]" }, # default none
22        );
23

DESCRIPTION

25       This Log::Any adapter prints log messages to screen (STDERR/STDOUT).
26       The messages are colored according to level (unless coloring is turned
27       off). It has a few other features: allow passing formatter, allow
28       setting level from some environment variables, add prefix/timestamps.
29
30       Parameters:
31
32       ·   min_level => STRING
33
34           Set logging level. Default is warning. If LOG_LEVEL environment
35           variable is set, it will be used instead. If TRACE environment
36           variable is set to true, level will be set to 'trace'. If DEBUG
37           environment variable is set to true, level will be set to 'debug'.
38           If VERBOSE environment variable is set to true, level will be set
39           to 'info'.If QUIET environment variable is set to true, level will
40           be set to 'error'.
41
42       ·   use_color => BOOL
43
44           Whether to use color or not. Default is true only when running
45           interactively (-t STDOUT returns true).
46
47       ·   colors => HASH
48
49           Customize colors. Hash keys are the logging methods, hash values
50           are colors supported by Term::ANSIColor.
51
52           The default colors are:
53
54            method/level                 color
55            ------------                 -----
56            trace                        yellow
57            debug                        (none, terminal default)
58            info, notice                 green
59            warning                      bold blue
60            error                        magenta
61            critical, alert, emergency   red
62
63       ·   stderr => BOOL
64
65           Whether to print to STDERR, default is true. If set to 0, will
66           print to STDOUT instead.
67
68       ·   formatter => CODEREF
69
70           Allow formatting message. If defined, message will be passed before
71           being colorized. Coderef will be passed:
72
73            ($self, $message)
74
75           and is expected to return the formatted message.
76
77           The default formatter can optionally prefix the message with extra
78           stuffs, depending on the content of LOG_PREFIX environment
79           variable, such as: elapsed time (e.g. "[0.023ms]") if LOG_PREFIX is
80           "elapsed".
81
82           NOTE: Log::Any 1.00+ now has a proxy object which allows
83           formatting/customization of message before it is sent to
84           adapter(s), so formatting does not have to be done on a per-adapter
85           basis. As an alternative to this attribute, you can also consider
86           using the proxy object or the (upcoming?)  global proxy object.
87
88       ·   default_level => STR (default: warning)
89
90           If no level-setting environment variables are defined, will default
91           to this level.
92

ENVIRONMENT

94   NO_COLOR
95       If defined, will disable color. Consulted before "COLOR".
96
97   COLOR
98       Can be set to 0 to explicitly disable colors. The default is to check
99       for "<-t STDOUT">.
100
101   LOG_LEVEL => str
102   QUIET => bool
103   VERBOSE => bool
104   DEBUG => bool
105   TRACE => bool
106       These environment variables can set the default for "min_level". See
107       documentation about "min_level" for more details.
108
109   LOG_PREFIX => str
110       The default formatter groks these variables. See documentation about
111       "formatter" about more details.
112

HOMEPAGE

114       Please visit the project's homepage at
115       <https://metacpan.org/release/Log-Any-Adapter-Screen>.
116

SOURCE

118       Source repository is at
119       <https://github.com/perlancar/perl-Log-Any-Adapter-ScreenColoredLevel>.
120

BUGS

122       Please report any bugs or feature requests on the bugtracker website
123       <https://rt.cpan.org/Public/Dist/Display.html?Name=Log-Any-Adapter-Screen>
124
125       When submitting a bug or request, please include a test-file or a patch
126       to an existing test-file that illustrates the bug or desired feature.
127

SEE ALSO

129       Originally inspired by Log::Log4perl::Appender::ScreenColoredLevel. The
130       old name for this adapter is Log::Any::Adapter::ScreenColoredLevel but
131       at some point I figure using a shorter name is better for my fingers.
132
133       Log::Any
134
135       Log::Log4perl::Appender::ScreenColoredLevel
136
137       Term::ANSIColor
138

AUTHOR

140       perlancar <perlancar@cpan.org>
141
143       This software is copyright (c) 2018, 2016, 2015, 2014, 2012, 2011 by
144       perlancar@cpan.org.
145
146       This is free software; you can redistribute it and/or modify it under
147       the same terms as the Perl 5 programming language system itself.
148
149
150
151perl v5.30.0                      2019-07-26      Log::Any::Adapter::Screen(3)
Impressum