X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=scpubgit%2FObject-Remote.git;a=blobdiff_plain;f=lib%2FObject%2FRemote%2FLogging.pm;h=f5416d650de5db7b6cb930a066bf28b169276876;hp=0cc02d75c8a4ee488aee311dac02f0873c26b70c;hb=0e090a216bf8825855f8ca70bcb7f0980b5f786d;hpb=b8176a97bbde19ddf305754cf2de7331e1aee19a diff --git a/lib/Object/Remote/Logging.pm b/lib/Object/Remote/Logging.pm index 0cc02d7..f5416d6 100644 --- a/lib/Object/Remote/Logging.pm +++ b/lib/Object/Remote/Logging.pm @@ -71,8 +71,12 @@ sub init_logging { my $format = $ENV{OBJECT_REMOTE_LOG_FORMAT}; my $selections = $ENV{OBJECT_REMOTE_LOG_SELECTIONS}; my %controller_should_log; + + unless (defined $ENV{OBJECT_REMOTE_LOG_FORWARDING} && $ENV{OBJECT_REMOTE_LOG_FORWARDING} ne '') { + $ENV{OBJECT_REMOTE_LOG_FORWARDING} = 1; + } - return unless defined $level; + return unless defined $level && $level ne ''; $format = "[%l %r] %s" unless defined $format; $selections = __PACKAGE__ unless defined $selections; %controller_should_log = _parse_selections($selections); @@ -111,9 +115,6 @@ sub init_remote_logging { my ($self, %controller_info) = @_; router()->_remote_metadata(\%controller_info); - #TODO having an instance of an object in the remote interpreter causes it to hang - #on exit intermitently or leave a zombie laying around frequently - not a bug limited - #to log forwarding router()->_forward_destination($controller_info{router}) if $ENV{OBJECT_REMOTE_LOG_FORWARDING}; } @@ -136,7 +137,7 @@ Object::Remote::Logging - Logging subsystem for Object::Remote $ENV{OBJECT_REMOTE_LOG_FORMAT} = '%l %t: %p::%m %s'; #and more $ENV{OBJECT_REMOTE_LOG_SELECTIONS} = 'Object::Remote::Logging Some::Other::Subclass'; $ENV{OBJECT_REMOTE_LOG_SELECTIONS} = '* -Object::Remote::Logging'; - $ENV{OBJECT_REMOTE_LOG_FORWARDING} = 0 || 1; #default 0 + $ENV{OBJECT_REMOTE_LOG_FORWARDING} = 0; #default 1 log_info { 'Trace log event' }; Dlog_verbose { "Debug event with Data::Dumper::Concise: $_" } { foo => 'bar' }; @@ -195,8 +196,8 @@ remote interpreter and the logger for the message is invoked in the local interp Sub-classes of Object::Remote::Logging will have log messages forwarded automatically. Loggers receive forwarded log messages exactly the same way as non-forwarded messages except a forwarded message includes extra metadata about the remote interpreter. Log -forwarding is not currently enabled by default; to enable it set the -OBJECT_REMOTE_LOG_FORWARDING environment variable to 1. See L. +forwarding is enabled by default but comes with a performance hit; to disable it set the +OBJECT_REMOTE_LOG_FORWARDING environment variable to 0. See L. =head1 EXPORTABLE SUBROUTINES @@ -228,7 +229,7 @@ to the block as the argument list and returned from the log method as a list. Works just like log_ and Dlog_ except returns only the first argument as a scalar value. - my $beverage = log_info { "Customer ordered $_[0]" } 'Coffee'; + my $beverage = logS_info { "Customer ordered $_[0]" } 'Coffee'; =back