Subject: | validate() deletes 'default' section from config |
Hi,
As I can see suggested usage is the following:
----
if ( $log->validate( config => \%new_config ) ) {
$log->reload( config => \%new_config );
}
----
But if there is 'default' section in %new_config it will not affect $log, cause validate() deletes it.
Section is deleted in _get_hash_config() subroutine of Log::Handler::Config module.
----
%default = %{ delete $config->{default} };
----
Please see example attached.
Surely I can use clone() for validation to avoid this problem, but it is not clear behaviour.
Please modify validate(), config() and reload() not to change passed config if it is possible.
In additional: could you please make static method for validate? To call it like that:
----
Log::Handler->validate( config => $config );
----
Subject: | test.pl |
#!/usr/bin/perl
use Data::Dumper;
use Log::Handler;
# use Clone qw(clone);
my $config = {
file => {
default => {
maxlevel => 'info',
},
error => {
filename => '/tmp/error.log',
},
}
};
my $log = Log::Handler->get_logger( 'myapp' );
if ( $log->validate( config => $config ) ) { # ( config => clone( $config ) )
print Dumper($config);
$log->config( config => $config );
}
if ( $log->is_info() ) {
print "INFO\n";
} else {
print "NOT INFO\n";
}