Log::Any::Plugin::Encode - Output message encoding for log adapters
version 0.012
# Set up some kind of logger. use Log::Any::Adapter; Log::Any::Adapter->set('SomeAdapter'); # Apply the Levels plugin to your logger use Log::Any::Plugin; Log::Any::Plugin->add('Encode', encoding => 'utf8'); # utf8 is default if not specified # In your modules use Log::Any qw($log); $log->error('error'); # output is <encoding> encoded, in this case UTF-8 # Applies to every log method.
This came about from noticing warnings of wide chars being output to adapter streams. This plugin may be inserted as needed to explicitly transform log messages into the configured encoding.
Configuration values are passed as key-value pairs when adding the plugin:
Log::Any::Plugin->add('Encode', encoding => 'utf8');
This implementation relies on the Encode module to perform encoding, refer to that for supported encodings.
Defaults to 'utf8' if not specified. An unknown encoding will throw an error.
There are no methods in this package which should be directly called by the user. Use Log::Any::Plugin->add() instead.
Private method called by Log::Any::Plugin->add()
Thanks to Strategic Data for sponsoring the development of this module.
Stephen Thirlwall <sdt@cpan.org>
This software is copyright (c) 2022, 2019, 2017, 2015, 2014 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.
To install Log::Any::Plugin, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Log::Any::Plugin
CPAN shell
perl -MCPAN -e shell install Log::Any::Plugin
For more information on module installation, please visit the detailed CPAN module installation guide.