system-introspector binary uses selector to get only system::introspector logs; tweak...
Tyler Riddle [Tue, 16 Oct 2012 01:31:26 +0000 (18:31 -0700)]
Makefile.PL
bin/system-introspector
lib/System/Introspector/Gatherer.pm
lib/System/Introspector/Gatherer/Report.pm

index f593f2d..d9de16b 100644 (file)
@@ -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
index da84e29..2d29bee 100755 (executable)
@@ -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;
index dceba95..7cd0f43 100644 (file)
@@ -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; 
index df26866..46c13cb 100644 (file)
@@ -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); 
 }