Debian Codegraph @

README

raw
1 NAME
2 Log::Any::Adapter::Screen - (ADOPTME) Send logs to screen, with colors
3 and some other features
4
5 VERSION
6 This document describes version 0.141 of Log::Any::Adapter::Screen (from
7 Perl distribution Log-Any-Adapter-Screen), released on 2023-11-21.
8
9 SYNOPSIS
10 use Log::Any::Adapter;
11 Log::Any::Adapter->set('Screen',
12 # min_level => 'debug', # default is 'warning'
13 # colors => { trace => 'bold yellow on_gray', ... }, # customize colors
14 # use_color => 1, # force color even when not interactive
15 # stderr => 0, # print to STDOUT instead of the default STDERR
16 # formatter => sub { "LOG: $_[1]" }, # default none
17 );
18
19 DESCRIPTION
20 This Log::Any adapter prints log messages to screen (STDERR/STDOUT). The
21 messages are colored according to level (unless coloring is turned off).
22 It has a few other features: allow passing formatter, allow setting
23 level from some environment variables, add prefix/timestamps.
24
25 Parameters:
26
27 * min_level => STRING
28
29 * log_level => STRING
30
31 Set logging level. Default is warning. If LOG_LEVEL environment
32 variable is set, it will be used instead. If TRACE environment
33 variable is set to true, level will be set to 'trace'. If DEBUG
34 environment variable is set to true, level will be set to 'debug'.
35 If VERBOSE environment variable is set to true, level will be set to
36 'info'.If QUIET environment variable is set to true, level will be
37 set to 'error'.
38
39 Log::Any adapters use parameter "log_level" instead of "min_level".
40 If both are present "min_level" takes precedence.
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 are
50 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 print
66 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 variable,
79 such as: elapsed time (e.g. "[0.023ms]") if LOG_PREFIX is "elapsed".
80
81 NOTE: Log::Any 1.00+ now has a proxy object which allows
82 formatting/customization of message before it is sent to adapter(s),
83 so formatting does not have to be done on a per-adapter basis. As an
84 alternative to this attribute, you can also consider using the proxy
85 object or the (upcoming?) global proxy object.
86
87 * default_level => STR (default: warning)
88
89 If no level-setting environment variables are defined, will default
90 to this level.
91
92 ENVIRONMENT
93 NO_COLOR
94 If defined, will disable color. Consulted before "COLOR".
95
96 COLOR
97 Can be set to 0 to explicitly disable colors. The default is to check
98 for "<-t STDOUT">.
99
100 LOG_LEVEL => str
101 QUIET => bool
102 VERBOSE => bool
103 DEBUG => bool
104 TRACE => bool
105 These environment variables can set the default for "min_level". See
106 documentation about "min_level" for more details.
107
108 LOG_PREFIX => str
109 The default formatter groks these variables. See documentation about
110 "formatter" about more details.
111
112 HOMEPAGE
113 Please visit the project's homepage at
114 <https://metacpan.org/release/Log-Any-Adapter-Screen>.
115
116 SOURCE
117 Source repository is at
118 <https://github.com/perlancar/perl-Log-Any-Adapter-Screen>.
119
120 SEE ALSO
121 Originally inspired by Log::Log4perl::Appender::ScreenColoredLevel. The
122 old name for this adapter is Log::Any::Adapter::ScreenColoredLevel but
123 at some point I figure using a shorter name is better for my fingers.
124
125 Log::Any
126
127 Log::Log4perl::Appender::ScreenColoredLevel
128
129 Term::ANSIColor
130
131 AUTHOR
132 perlancar <[email protected]>
133
134 CONTRIBUTORS
135 * Mikko Koivunalho <[email protected]>
136
137 * Steven Haryanto <[email protected]>
138
139 CONTRIBUTING
140 To contribute, you can send patches by email/via RT, or send pull
141 requests on GitHub.
142
143 Most of the time, you don't need to build the distribution yourself. You
144 can simply modify the code, then test via:
145
146 % prove -l
147
148 If you want to build the distribution (e.g. to try to install it locally
149 on your system), you can install Dist::Zilla,
150 Dist::Zilla::PluginBundle::Author::PERLANCAR,
151 Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two
152 other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps
153 required beyond that are considered a bug and can be reported to me.
154
155 COPYRIGHT AND LICENSE
156 This software is copyright (c) 2023, 2018, 2016, 2015, 2014, 2012, 2011
157 by perlancar <[email protected]>.
158
159 This is free software; you can redistribute it and/or modify it under
160 the same terms as the Perl 5 programming language system itself.
161
162 BUGS
163 Please report any bugs or feature requests on the bugtracker website
164 <https://rt.cpan.org/Public/Dist/Display.html?Name=Log-Any-Adapter-Scree
165 n>
166
167 When submitting a bug or request, please include a test-file or a patch
168 to an existing test-file that illustrates the bug or desired feature.
169