From: Tyler Riddle Date: Wed, 7 Nov 2012 03:38:33 +0000 (-0800) Subject: weaken connections to log router; fixes for no current method name X-Git-Tag: v0.003001_01~85 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b43174a123aae89a1d3666ffd4d7b9d11ad4846c;p=scpubgit%2FObject-Remote.git weaken connections to log router; fixes for no current method name --- diff --git a/lib/Object/Remote/Logging.pm b/lib/Object/Remote/Logging.pm index 22860ed..d2c92d1 100644 --- a/lib/Object/Remote/Logging.pm +++ b/lib/Object/Remote/Logging.pm @@ -7,7 +7,7 @@ use Exporter::Declare; extends 'Log::Contextual'; -exports(qw( router )); +exports(qw( router arg_levels )); sub router { our $Router_Instance ||= do { diff --git a/lib/Object/Remote/Logging/Logger.pm b/lib/Object/Remote/Logging/Logger.pm index 16b278d..83e3a0e 100644 --- a/lib/Object/Remote/Logging/Logger.pm +++ b/lib/Object/Remote/Logging/Logger.pm @@ -59,11 +59,15 @@ sub _log { sub _create_format_lookup { my ($self, $level, $metadata, $content) = @_; + my $method = $metadata->{method}; + + $method = '(none)' unless defined $method; + return { '%' => '%', t => $self->_render_time($metadata->{timestamp}), r => $self->_render_remote($metadata->{object_remote}), s => $self->_render_log(@$content), l => $level, - p => $metadata->{package}, m => $metadata->{method}, + p => $metadata->{package}, m => $method, f => $metadata->{filename}, i => $metadata->{line}, }; diff --git a/lib/Object/Remote/Logging/Router.pm b/lib/Object/Remote/Logging/Router.pm index ffc51b9..ee40377 100644 --- a/lib/Object/Remote/Logging/Router.pm +++ b/lib/Object/Remote/Logging/Router.pm @@ -1,6 +1,7 @@ package Object::Remote::Logging::Router; use Moo; +use Scalar::Util qw(weaken); with 'Log::Contextual::Role::Router'; with 'Object::Remote::Role::LogForwarder'; @@ -65,7 +66,7 @@ sub handle_log_request { @caller_info = caller($caller_level + 1); $metadata{method} = $caller_info[3]; - $metadata{method} =~ s/^${package}:://; + $metadata{method} =~ s/^${package}::// if defined $metadata{method}; foreach my $logger ($self->_get_loggers(%metadata)) { $logger->$level([ $generator->(@args) ], \%metadata); @@ -83,6 +84,7 @@ sub connect { } push(@{$self->_connections}, $wrapped); + weaken($self->_connections->[-1]); } sub _clean_connections {