improved readability of default logging logic

This commit is contained in:
Matt Simerson 2012-05-04 14:12:46 -04:00 committed by Robert
parent d80a347afe
commit 6031e49da8
2 changed files with 20 additions and 19 deletions

View File

@ -125,17 +125,18 @@ sub varlog {
$self->load_logging; # in case we don't have this loaded yet $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 ) { return if $rc == DECLINED || $rc == OK; # plugin success
# no logging plugins registered so fall back to STDERR return if $trace > $TraceLevel;
warn join(" ", $$ .
(defined $plugin && defined $hook ? " $plugin plugin ($hook):" : # no logging plugins registered, fall back to STDERR
defined $plugin ? " $plugin plugin:" : my $prefix = defined $plugin && defined $hook ? " $plugin plugin ($hook):" :
defined $hook ? " running plugin ($hook):" : ""), defined $plugin ? " $plugin plugin:" :
@log), "\n" defined $hook ? " running plugin ($hook):" : '';
if $trace <= $TraceLevel;
} warn join(' ', $$ . $prefix, @log), "\n";
} }
sub clear_config_cache { sub clear_config_cache {
@ -515,7 +516,6 @@ sub hook_responder {
my ($self, $hook, $msg, $args) = @_; my ($self, $hook, $msg, $args) = @_;
#my $t1 = $SAMPLER->("hook_responder", undef, 1); #my $t1 = $SAMPLER->("hook_responder", undef, 1);
my $code = shift @$msg; my $code = shift @$msg;
my $responder = $hook . '_respond'; my $responder = $hook . '_respond';

View File

@ -28,16 +28,17 @@ sub hook_logging {
# Don't log your own log entries! If this is the only logging plugin # 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 # then these lines will not be logged at all. You can safely comment
# out this line and it will not cause an infinite loop. # 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 return DECLINED if $trace > $self->{_level};
join(" ", $$ .
(defined $plugin ? " $plugin plugin:" :
defined $hook ? " running plugin ($hook):" : ""),
@log), "\n"
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 =head1 NAME