1Log::Any::Adapter::TAP(U3s)er Contributed Perl DocumentatLioogn::Any::Adapter::TAP(3)
2
3
4
6 Log::Any::Adapter::TAP - Logging adapter suitable for use in TAP
7 testcases
8
10 version 0.003003
11
13 When running testcases, you probably want to see some of your logging
14 output. One sensible approach is to have all "warn" and more serious
15 messages emitted as "diag" output on STDERR, and less serious messages
16 emitted as "note" comments on STDOUT.
17
18 So, thats what this logging adapter does. Simply say
19
20 use Log::Any::Adapter 'TAP';
21
22 at the start of your testcase, and now you have your logging output as
23 part of your TAP stream.
24
25 By default, "debug" and "trace" are suppressed, but you can enable them
26 with "TAP_LOG_FILTER" or the "filter" attribute. See below.
27
29 TAP_LOG_FILTER
30 Specify the default filter value. See attribute "filter" for details.
31
32 You may also specify defaults per-category, using this syntax:
33
34 $default_level,$package_1=$level,...,$package_n=$level
35
36 So, for example:
37
38 TAP_LOG_FILTER=trace,MyPackage=none,NoisyPackage=warn prove -lv
39
40 TAP_LOG_ORIGIN
41 Set this variable to 1 to show which category the message came from, or
42 2 to see the file and line number it came from, or 3 to see both.
43
44 TAP_LOG_SHOW_USAGE
45 Defaults to true, which prints a TAP comment briefing the user about
46 these environment variables when Log::Any::Adapter::TAP is first
47 loaded.
48
49 Set TAP_LOG_SHOW_USAGE=0 to suppress this message.
50
52 filter
53 use Log::Any::Adapter 'TAP', filter => 'info';
54 use Log::Any::Adapter 'TAP', filter => 'debug+3';
55
56 Messages with a log level equal to or less than the filter are
57 suppressed.
58
59 Defaults to "TAP_LOG_FILTER", or "debug" which suppresses "debug" and
60 "trace" messages.
61
62 Filter may be:
63
64 • Any of the log level names or level aliases defined in Log::Any.
65
66 • "none" or "undef", to filter nothing (print all log levels).
67
68 • A value of "all", to filter everything (print nothing).
69
70 The filter level may end with a "+N" or "-N" indicating an offset from
71 the named level. The numeric values increase with importance of the
72 message, so "debug-1" is equivalent to "trace" and "debug+1" is
73 equivalent to "info". This differs from syslog, where increasing
74 numbers are less important. (why did they choose that??)
75
76 dumper (DEPRECATED, unusable in Log::Any >= 0.9)
77 use Log::Any::Adapter 'TAP', dumper => sub { my $val=shift; ... };
78
79 This feature lets you use a custom dumper in the printf-style logging
80 functions. However, these are no longer handled by the adapter in new
81 versions of Log::Any, so you need to use a custom Proxy class in your
82 log-producing module.
83
85 new
86 See "new" in Log::Any::Adapter::Base. Accepts the above attributes.
87
88 write_msg
89 $self->write_msg( $level_name, $message_string )
90
91 This is an internal method which all the other logging methods call.
92 You can override it if you want to create a derived logger that handles
93 line wrapping differently, or write to different file handles.
94
95 default_dumper
96 $dumper= $class->default_dumper;
97 $string = $dumper->( $perl_data );
98
99 Default value for the 'dumper' attribute.
100
101 This returns a coderef which can dump a value in "some human readable
102 format". Currently it uses Data::Dumper with a max depth of 4. Do not
103 depend on this default; it is only for human consumption, and might
104 change to a more friendly format in the future.
105
107 This module has all the standard logging methods from "LOG LEVELS" in
108 Log::Any.
109
110 Note that the regular logging methods are only specified to take a
111 single string. This module in the past supported passing objects as
112 additional parameters, and having them stringified with a custom
113 dumper, caatching exceptions thrown during stringification. With the
114 new Log::Any design, these things are decided in the producing module,
115 so these features are no longer possible.
116
117 If this module does receive multiple arguments or have its printf-
118 formatting methods called, it does the following:
119
120 For regular logging functions (i.e. "warn", "info") the arguments are
121 stringified and concatenated. Errors during stringify or printing are
122 not caught.
123
124 For printf-like logging functions (i.e. "warnf", "infof") reference
125 arguments are passed to "$self->dumper" before passing them to sprintf.
126 Errors are not caught here either.
127
128 For any log level below "info", errors ARE caught with an "eval" and
129 printed as a warning. This is to prevent sloppy debugging code from
130 ever crashing a production system. Also, references are passed to
131 "$self->dumper" even for the regular methods.
132
134 Michael Conrad <mike@nrdvana.net>
135
137 This software is copyright (c) 2016 by Michael Conrad.
138
139 This is free software; you can redistribute it and/or modify it under
140 the same terms as the Perl 5 programming language system itself.
141
142
143
144perl v5.38.0 2023-07-20 Log::Any::Adapter::TAP(3)