forwarded log messages now include a forwarded flag in the metadata
Tyler Riddle [Fri, 21 Dec 2012 22:13:37 +0000 (14:13 -0800)]
lib/Object/Remote/Logging.pm
lib/Object/Remote/Role/LogForwarder.pm

index 4571c0a..1075016 100644 (file)
@@ -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;
   });
 }
 
index d3968d2..4bf2ecc 100644 (file)
@@ -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 $@;