From: Tyler Riddle Date: Sat, 10 Nov 2012 17:12:36 +0000 (-0800) Subject: better lookup method in log any injector; %n adds newline in log format string X-Git-Tag: v0.003001_01~67 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=293fb1ee44fb32ff692278802149f42a5e391197;p=scpubgit%2FObject-Remote.git better lookup method in log any injector; %n adds newline in log format string --- diff --git a/lib/Object/Remote/FatNode.pm b/lib/Object/Remote/FatNode.pm index 77e6928..41ad696 100644 --- a/lib/Object/Remote/FatNode.pm +++ b/lib/Object/Remote/FatNode.pm @@ -61,7 +61,9 @@ my @file_names = keys %mods; my @before_inc = grep { filter_not_core() } @file_names; my @after_inc; -#TODO obviously this should be made into a method or configurable some how +#TODO this is the wrong path to go down - fork() will bring +#the env vars with it and the ssh connector can handle +#forwarding the env vars my $env_pass = ''; if (defined($ENV{OBJECT_REMOTE_LOG_LEVEL})) { my $level = $ENV{OBJECT_REMOTE_LOG_LEVEL}; diff --git a/lib/Object/Remote/Logging.pm b/lib/Object/Remote/Logging.pm index 5901b0c..1c45b45 100644 --- a/lib/Object/Remote/Logging.pm +++ b/lib/Object/Remote/Logging.pm @@ -281,8 +281,8 @@ value will default to 1 or can be specified as an argument. =head1 LEVEL NAMES -Object::Remote uses an ordered list of log level names with the minimum level -first and the maximum level last. The list of level names can be accessed via +Object::Remote uses an ordered list of log level names with the lowest level +first and the highest level last. The list of level names can be accessed via the arg_levels method which is exportable to the consumer of this class. The log level names are: diff --git a/lib/Object/Remote/Logging/LogAnyInjector.pm b/lib/Object/Remote/Logging/LogAnyInjector.pm index 77d75b7..70c5384 100644 --- a/lib/Object/Remote/Logging/LogAnyInjector.pm +++ b/lib/Object/Remote/Logging/LogAnyInjector.pm @@ -28,16 +28,15 @@ sub AUTOLOAD { #skip DESTROY and friends return if $log_level =~ m/^[A-Z]+$/; - if ($log_level =~ s/f$//) { - my $format = shift(@content); - $generator = sub { sprintf($format, @content) }; + if ($log_contextual_level = $LEVEL_NAME_MAP{$log_level}) { + $generator = sub { @content }; + } elsif(($log_level =~ s/f$//) && ($log_contextual_level = $LEVEL_NAME_MAP{$log_level})) { + my $format = shift(@content); + $generator = sub { sprintf($format, @content) }; } else { - $generator = sub { @content }; + croak "invalid log level: $log_level"; } - - $log_contextual_level = $LEVEL_NAME_MAP{$log_level}; - croak "invalid log level name: $log_level" unless defined $log_contextual_level; - + router->handle_log_request({ controller => 'Log::Any', package => scalar(caller), diff --git a/lib/Object/Remote/Logging/Logger.pm b/lib/Object/Remote/Logging/Logger.pm index 65b42b9..e53dbf3 100644 --- a/lib/Object/Remote/Logging/Logger.pm +++ b/lib/Object/Remote/Logging/Logger.pm @@ -88,7 +88,8 @@ sub _create_format_lookup { $method = '(none)' unless defined $method; return { - '%' => '%', t => $self->_render_time($metadata->{timestamp}), + '%' => '%', 'n' => "\n", + t => $self->_render_time($metadata->{timestamp}), r => $self->_render_remote($metadata->{object_remote}), s => $self->_render_log(@$content), l => $level, c => $metadata->{controller}, p => $metadata->{package}, m => $method,