From: Tyler Riddle Date: Fri, 21 Dec 2012 22:13:37 +0000 (-0800) Subject: forwarded log messages now include a forwarded flag in the metadata X-Git-Tag: v0.003001_01~22 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=08435f11e57bbd6e01f4e52382f58b22f71358ad;p=scpubgit%2FObject-Remote.git forwarded log messages now include a forwarded flag in the metadata --- diff --git a/lib/Object/Remote/Logging.pm b/lib/Object/Remote/Logging.pm index 4571c0a..1075016 100644 --- a/lib/Object/Remote/Logging.pm +++ b/lib/Object/Remote/Logging.pm @@ -108,14 +108,15 @@ sub init_logging { router()->connect(sub { my $controller = $_[1]->{controller}; my $will_log = $controller_should_log{$controller}; + my $remote_info = $_[1]->{object_remote}; $will_log = $controller_should_log{'*'} unless defined $will_log; return unless $will_log; #skip things from remote hosts because they log to STDERR #when OBJECT_REMOTE_LOG_LEVEL is in effect - return if $_[1]->{remote}->{object_remote}; - $logger + return if $remote_info->{forwarded}; + return $logger; }); } diff --git a/lib/Object/Remote/Role/LogForwarder.pm b/lib/Object/Remote/Role/LogForwarder.pm index d3968d2..4bf2ecc 100644 --- a/lib/Object/Remote/Role/LogForwarder.pm +++ b/lib/Object/Remote/Role/LogForwarder.pm @@ -12,7 +12,14 @@ after _deliver_message => sub { my ($self, $level, $generator, $args, $metadata) = @_; my $package = $metadata->{package}; my $destination = $self->_forward_destination; + my %metadata = %$metadata; our $reentrant; + + if (defined $metadata->{object_remote}) { + $metadata{object_remote} = { %{$metadata->{object_remote}} }; + } + + $metadata{object_remote}->{forwarded} = 1; return unless $self->enable_forward; return unless defined $destination; @@ -25,7 +32,7 @@ after _deliver_message => sub { local $reentrant = $package; - eval { $destination->_deliver_message($level, $generator, $args, $metadata) }; + eval { $destination->_deliver_message($level, $generator, $args, \%metadata) }; if ($@ && $@ !~ /^Attempt to use Object::Remote::Proxy backed by an invalid handle/) { die $@;