NAME
Log::Any::Adapter::Multiplexor - Run any Log::Any:Adapter together
VERSION
version 0.03
SYNOPSIS
#log warn message to a file, but info message to Stdout
use Log::Any '$log';
use Log::Any::Adapter;
use Log::Any::Adapter::Multiplexor;
#Create Log::Any::Adapter::Multiplexor object
my $multiplexor = Log::Any::Adapter::Multiplexor->new(
$log,
'error' => ['Log::Any::Adapter::File', 'log.txt'],
'info' => ['Log::Any::Adapter::Stdout'],
);
#Log message to file log.txt
$log->error("Test error");
#Log message to Stdout
$log->info("Test info");
#You can override the behavior of log level
#Example: Send warning log message to file warn_log.txt
$multiplexor->set_logger('warning', 'Log::Any::Adapter::File', 'warn_log.txt');
$log->warning('Warning message');
#Combine log level 'info' and 'debug'
$multiplexor->combine('info', 'debug');
$log->info($message);
#Equals to:
$log->info($message);
$log->debug($message);
DESCRIPTION
Log::Any::Adapter::Multiplexor connects any Log::Any::Adapter to use together
Functions
Specification function
new
my $multiplexor = Log::Any::Adapter::Multiplexor->new($log, %param);
$log - $Log::Any::log object
%param
key => Log level name
value => Arrayref ['Adapter name', @params]
set_logger
Set or override exists logger for Log::Any::Adapter::Multiplexor object
$multiplexor->set_logger($log_level, $adapter, @param);
$log_level => Log levels (e.g. warning, info, error)
$adapter => Log::Any::Adapter for this log level (etc 'Log::Any::Adapter::File)
@param => Adapter params (e.g. filename)
combine
Duplicated logs from different log levels
$multiplexor->combine('info', 'debug');
$log->info($message);
#equals to
$log->info($message);
$log->debug($message);
uncombine
Delete associations of log levels $multiplexor->uncombine();
DEPENDENCE
AUTHORS
Pavel Andryushin <vrag867@gmail.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2017 by Pavel Andryushin.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.