From: Tyler Riddle Date: Tue, 16 Oct 2012 01:31:26 +0000 (-0700) Subject: system-introspector binary uses selector to get only system::introspector logs; tweak... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=599b536973ae300bb4e1b0403fde0538da1cd215;p=scpubgit%2FSystem-Introspector.git system-introspector binary uses selector to get only system::introspector logs; tweak log levels --- diff --git a/Makefile.PL b/Makefile.PL index f593f2d..d9de16b 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -28,7 +28,6 @@ my %requires = ( 'File::Tree::Snapshot' => 0, 'Object::Remote' => 0, 'JSON::Diffable' => 0, - 'Log::Contextual', => 0, ); # have to do this since old EUMM dev releases miss the eval $VERSION line diff --git a/bin/system-introspector b/bin/system-introspector index da84e29..2d29bee 100755 --- a/bin/system-introspector +++ b/bin/system-introspector @@ -36,31 +36,28 @@ if (defined($debug) && ! defined($log_level)) { } my ($stderr_destination, $stdout_destination, $warn_destination); +my $selector = sub { $_[0]->{package} =~ m/^System::Introspector/; }; -$warn_destination = Object::Remote::LogDestination->new({ - logger => System::Introspector::Logger::WarnOutput->new({ - levels_upto => 'warn', - }), -}); - -$warn_destination->connect(System::Introspector::Logger->arg_router); - -$stdout_destination = Object::Remote::LogDestination->new( - logger => System::Introspector::Logger::VerboseOutput->new({ - levels => ['info'], - }), -); - -$stdout_destination->connect(System::Introspector::Logger->arg_router); - +#suppress default output if a log level was specified if (defined($log_level)) { $stderr_destination = Object::Remote::LogDestination->new( logger => System::Introspector::Logger::Output->new({ levels_upto => $log_level, }), - ); - - $stderr_destination->connect(System::Introspector::Logger->arg_router); + )->select(System::Introspector::Logger->arg_router, $selector); + +} else { + $stdout_destination = Object::Remote::LogDestination->new( + logger => System::Introspector::Logger::VerboseOutput->new({ + levels => ['info'], + }), + )->select(System::Introspector::Logger->arg_router, $selector); + + $warn_destination = Object::Remote::LogDestination->new({ + logger => System::Introspector::Logger::WarnOutput->new({ + levels_upto => 'warn', + }), + })->select(System::Introspector::Logger->arg_router, $selector); } $config_file = "$storage_dir/main.conf" unless defined $config_file; diff --git a/lib/System/Introspector/Gatherer.pm b/lib/System/Introspector/Gatherer.pm index dceba95..7cd0f43 100644 --- a/lib/System/Introspector/Gatherer.pm +++ b/lib/System/Introspector/Gatherer.pm @@ -25,7 +25,6 @@ sub gather_all { log_debug { "Using '$module' for this gather" }; my $module_name = use_module($module); log_trace { "Finished loading '$module'; returned value was '$module_name'" }; - #my $instance = $module_name->new::on('-', $args); my $instance = $module_name->new($args); log_trace { "Finished constructing '$module_name'; starting gather" }; my $probe_data = $instance->gather; diff --git a/lib/System/Introspector/Gatherer/Report.pm b/lib/System/Introspector/Gatherer/Report.pm index df26866..46c13cb 100644 --- a/lib/System/Introspector/Gatherer/Report.pm +++ b/lib/System/Introspector/Gatherer/Report.pm @@ -100,7 +100,7 @@ sub get_probe_data { log_trace { "Getting report data for probe name '$name'" }; my $data = $self->data->{$name}; return $data unless $self->tied_output; - log_info { "Probe data is coming from tied objects" }; + log_debug { "Probe data is coming from tied objects" }; return System::Introspector::Gatherer::Report::Hash->_anonymous_tie($data); }