Log::Any::Adapter::TAP - Logging adapter suitable for use in TAP testcases


version 0.003003


When running testcases, you probably want to see some of your logging output. 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, thats 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.

By default, debug and trace are suppressed, but you can enable them with "TAP_LOG_FILTER" or the "filter" attribute. See below.



Specify the default filter value. See attribute "filter" for details.

You may also specify defaults per-category, using this syntax:


So, for example:

  TAP_LOG_FILTER=trace,MyPackage=none,NoisyPackage=warn prove -lv


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.


Defaults to true, which prints a TAP comment briefing the user about these environment variables when Log::Any::Adapter::TAP is first loaded.

Set TAP_LOG_SHOW_USAGE=0 to suppress this message.



  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.

  • none or undef, 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.



See "new" in Log::Any::Adapter::Base. Accepts the above attributes.


  $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.


  $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.


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, caatching 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->dumper before passing them to sprintf. Errors are not caught here either.

For any log level below info, errors ARE caught with an eval and printed as a warning. This is to prevent sloppy debugging code from ever crashing a production system. Also, references are passed to $self->dumper even for the regular methods.


Michael Conrad <>


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.