improved readability of default logging logic
This commit is contained in:
parent
d80a347afe
commit
6031e49da8
@ -125,17 +125,18 @@ sub varlog {
|
||||
|
||||
$self->load_logging; # in case we don't have this loaded yet
|
||||
|
||||
my ($rc) = $self->run_hooks_no_respond("logging", $trace, $hook, $plugin, @log);
|
||||
my ($rc) = $self->run_hooks_no_respond("logging", $trace, $hook, $plugin, @log)
|
||||
or return;
|
||||
|
||||
unless ( $rc and $rc == DECLINED or $rc == OK ) {
|
||||
# no logging plugins registered so fall back to STDERR
|
||||
warn join(" ", $$ .
|
||||
(defined $plugin && defined $hook ? " $plugin plugin ($hook):" :
|
||||
defined $plugin ? " $plugin plugin:" :
|
||||
defined $hook ? " running plugin ($hook):" : ""),
|
||||
@log), "\n"
|
||||
if $trace <= $TraceLevel;
|
||||
}
|
||||
return if $rc == DECLINED || $rc == OK; # plugin success
|
||||
return if $trace > $TraceLevel;
|
||||
|
||||
# no logging plugins registered, fall back to STDERR
|
||||
my $prefix = defined $plugin && defined $hook ? " $plugin plugin ($hook):" :
|
||||
defined $plugin ? " $plugin plugin:" :
|
||||
defined $hook ? " running plugin ($hook):" : '';
|
||||
|
||||
warn join(' ', $$ . $prefix, @log), "\n";
|
||||
}
|
||||
|
||||
sub clear_config_cache {
|
||||
@ -515,7 +516,6 @@ sub hook_responder {
|
||||
my ($self, $hook, $msg, $args) = @_;
|
||||
|
||||
#my $t1 = $SAMPLER->("hook_responder", undef, 1);
|
||||
|
||||
my $code = shift @$msg;
|
||||
|
||||
my $responder = $hook . '_respond';
|
||||
|
@ -28,16 +28,17 @@ sub hook_logging {
|
||||
# Don't log your own log entries! If this is the only logging plugin
|
||||
# then these lines will not be logged at all. You can safely comment
|
||||
# out this line and it will not cause an infinite loop.
|
||||
return DECLINED if defined $plugin and $plugin eq $self->plugin_name;
|
||||
return DECLINED if defined $plugin && $plugin eq $self->plugin_name;
|
||||
|
||||
warn
|
||||
join(" ", $$ .
|
||||
(defined $plugin ? " $plugin plugin:" :
|
||||
defined $hook ? " running plugin ($hook):" : ""),
|
||||
@log), "\n"
|
||||
if ($trace <= $self->{_level});
|
||||
return DECLINED if $trace > $self->{_level};
|
||||
|
||||
return DECLINED;
|
||||
my $prefix = defined $plugin && defined $hook ? " $plugin plugin ($hook):" :
|
||||
defined $plugin ? " $plugin plugin:" :
|
||||
defined $hook ? " running plugin ($hook):" : ''),
|
||||
|
||||
warn join(' ', $$ . $prefix, @log), "\n";
|
||||
|
||||
return DECLINED;
|
||||
}
|
||||
|
||||
=head1 NAME
|
||||
|
Loading…
Reference in New Issue
Block a user