use System::Introspector::State;
use File::Tree::Snapshot;
use System::Introspector::Config;
-use System::Introspector::Logger qw(:log);
+use System::Introspector::Logger qw(:log get_router);
use System::Introspector::Logger::VerboseOutput;
use System::Introspector::Logger::Output;
use System::Introspector::Logger::WarnOutput;
'g|group=s' => \my @update_groups,
'd|debug' => \my $debug,
'l|log-level=s' => \my $log_level,
+ 'L|log-remote' => \my $log_remote,
'h|help' => sub { pod2usage(0) },
) or pod2usage(2);
$log_level = 'debug';
}
-my ($stderr_destination, $stdout_destination, $warn_destination);
-my $selector = sub { $_[0]->{package} =~ m/^System::Introspector/; };
-
-#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,
- }),
- )->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);
+ my $logger = Object::Remote::Logging::Logger->new(
+ min_level => lc($log_level),
+ level_names => Object::Remote::Logging::arg_levels(),
+ );
+
+ get_router()->connect(sub {
+ return unless $_[1]->{controller} eq 'System::Introspector::Logger';
+ if (! defined $log_remote && defined $_[1]->{object_remote}) {
+ return;
+ }
+ $logger
+ });
}
$config_file = "$storage_dir/main.conf" unless defined $config_file;
package System::Introspector::Logger::TestOutput;
-use Log::Contextual::WarnLogger;
-use base qw ( Log::Contextual::SimpleLogger );
+use base qw ( Object::Remote::Logging::Logger );
#
#we want the code blocks in the log lines to execute but not
#output anything so turn this into a null logger
-sub _log { }
+sub _output { }
package main;
-use Object::Remote::Logging qw( :log );
-use Object::Remote::LogDestination;
+use System::Introspector::Logger qw( :log get_router );
#make sure to enable execution of every logging code block
#by setting the log level as high as it can go
- my $____LOG_DESTINATION = Object::Remote::LogDestination->new(
- logger => System::Introspector::Logger::TestOutput->new({ levels_upto => 'trace' }),
- );
-
- $____LOG_DESTINATION->connect(Object::Remote::Logging->arg_router);
+get_router->connect(System::Introspector::Logger::TestOutput->new(
+ min_level => 'trace', max_level => 'error',
+ level_names => Object::Remote::Logging->arg_levels(),
+));
1;