Log::An...er::TAP(3)
π
Log::An...er::TAP(3) π
okay so this page is from the User Contributed Perl Documentation shelf, and it's literally the Log::An...er::TAP(3) manual β it's giving test-logging main character energy and we're obsessed β¨
π NAME π
Log::Any::Adapter::TAP β a logging adapter suitable for use in TAP testcases. periodt.
πΈ VERSION πΈ
version 0.003003 β noted, bestie π
π¦ DESCRIPTION π¦
When you're running testcases, you probably want to actually see some of your logging output, right? One sensible approach is to have all warn and more serious messages emitted as diag output on STDERR, and less serious messages emitted as note comments on STDOUT π
So yeah, that's exactly what this logging adapter does. Simply say
use Log::Any::Adapter 'TAP';
at the start of your testcase, and now you have your logging output as part of your TAP stream. the way that this plugs into your testcase is honestly iconic π«Ά
By default, debug and trace are suppressed, but you can enable them with TAP_LOG_FILTER or the filter attribute. See below, bestie π
π ENVIRONMENT π
π TAP_LOG_FILTER π
Specify the default filter value. See attribute filter for details.
You may also specify defaults per-category, using this syntax:
$default_level,$package_1=$level,...,$package_n=$level
So, for example:
TAP_LOG_FILTER=trace,MyPackage=none,NoisyPackage=warn prove -lv
π¦ TAP_LOG_ORIGIN π¦
Set this variable to 1 to show which category the message came from, or 2 to see the file and line number it came from, or 3 to see both. iykyk π
π TAP_LOG_SHOW_USAGE π
Defaults to true, which prints a TAP comment briefing the user about these environment variables when Log::Any::Adapter::TAP is first loaded. highkey useful.
Set TAP_LOG_SHOW_USAGE=0 to suppress this message. no cap, it's that simple π
π ATTRIBUTES π
πΈ filter πΈ
use Log::Any::Adapter 'TAP', filter => 'info';
use Log::Any::Adapter 'TAP', filter => 'debug+3';
Messages with a log level equal to or less than the filter are suppressed.
Defaults to TAP_LOG_FILTER, or debug which suppresses debug and trace messages.
Filter may be:
- Any of the log level names or level aliases defined in
Log::Any. noneorundef, to filter nothing (print all log levels).- A value of
all, to filter everything (print nothing).
The filter level may end with a +N or -N indicating an offset from the named level. The numeric values increase with importance of the message, so debug-1 is equivalent to trace and debug+1 is equivalent to info. This differs from syslog, where increasing numbers are less important. (why did they choose that?? π)
π dumper (DEPRECATED, unusable in Log::Any >= 0.9) π
use Log::Any::Adapter 'TAP', dumper => sub { my $val=shift; ... };
This feature lets you use a custom dumper in the printf-style logging functions. However, these are no longer handled by the adapter in new versions of Log::Any, so you need to use a custom Proxy class in your log-producing module. rip to that vibe π
π§ METHODS π§
π new π
See "new" in Log::Any::Adapter::Base. Accepts the above attributes.
π¦ write_msg π¦
$self->write_msg( $level_name, $message_string )
This is an internal method which all the other logging methods call. You can override it if you want to create a derived logger that handles line wrapping differently, or write to different file handles. slay, customization π
π default_dumper π
$dumper= $class->default_dumper;
$string = $dumper->( $perl_data );
Default value for the 'dumper' attribute.
This returns a coderef which can dump a value in "some human readable format". Currently it uses Data::Dumper with a max depth of 4. Do not depend on this default; it is only for human consumption, and might change to a more friendly format in the future. lowkey important warning, bestie β οΈ
π₯ LOGGING METHODS π₯
This module has all the standard logging methods from "LOG LEVELS" in Log::Any.
Note that the regular logging methods are only specified to take a single string. This module in the past supported passing objects as additional parameters, and having them stringified with a custom dumper, catching exceptions thrown during stringification. With the new Log::Any design, these things are decided in the producing module, so these features are no longer possible.
If this module does receive multiple arguments or have its printf-formatting methods called, it does the following:
- For regular logging functions (i.e.
warn,info) the arguments are stringified and concatenated. Errors during stringify or printing are not caught. - For printf-like logging functions (i.e.
warnf,infof) reference arguments are passed to$self->dumperbefore passing them tosprintf. Errors are not caught here either. - For any log level below
info, errors ARE caught with anevaland printed as a warning. This is to prevent sloppy debugging code from ever crashing a production system. Also, references are passed to$self->dumpereven for the regular methods.
π AUTHOR π
Michael Conrad <mike@nrdvana.net> β iconic π
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2016 by Michael Conrad.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
periodt π
okay that's the whole page, bestie π«Ά brought to you by perl v5.32.1 and dated 2025-01-18 β stay slay, keep your TAP stream cute β¨
π¦ where this page comes from
- epel 9: perl-Log-Any-Adapter-TAP 0.003003-19.el9 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms