NAME

Log::Any::Plugin::Stringify - Custom argument stringification plugin for log adapters

VERSION

version 0.002

SYNOPSIS

# Set up some kind of logger
use Log::Any::Adapter;
Log::Any::Adapter->set('SomeAdapter');

# Apply your own argument stringifier.
use Log::Any::Plugin;
Log::Any::Plugin->add('Stringify', \&my_stringifier);

DESCRIPTION

Log::Any logging functions are only defined to have a single $msg argument. Some adapters accept multiple arguments (like print does), but many don't. You may also want to do some sort of stringification of hash and list refs.

Log::Any::Plugin::Stringify allows you to inject an argument stringification function into every logging call, so that when you write this:

$log->error( ... );

you effectively get this:

$log->error( my_function( ... ) );

CONFIGURATION

These configuration values are passed as key-value pairs: Log::Any::Plugin->add('Stringify', stringifier => \&my_func);

stringifier => &my_func

The stringifier function takes a list of arguments and should return a single string.

See default_stringifier below for the default stringifier.

METHODS

There are no methods in this package which should be directly called by the user. Use Log::Any::Plugin->add() instead.

install

Private method called by Log::Any::Plugin->add()

default_stringifier

The default stringifier function if none is supplied. Listrefs and hashrefs are expanded by Data::Dumper, and the whole lot is concatenated into one string.

SEE ALSO

Log::Any::Plugin

ACKNOWLEDGEMENTS

Thanks to Strategic Data for sponsoring the development of this module.

AUTHOR

Stephen Thirlwall <sdt@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Stephen Thirlwall.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.