From: Tyler Riddle Date: Thu, 13 Sep 2012 00:25:34 +0000 (-0700) Subject: update command line logging feature X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6ea021d8bfd262978d58d203d9959cc464aec12d;p=scpubgit%2FSystem-Introspector.git update command line logging feature --- diff --git a/bin/system-introspector b/bin/system-introspector index 88e88ae..ece49c7 100755 --- a/bin/system-introspector +++ b/bin/system-introspector @@ -6,7 +6,11 @@ use Pod::Usage; use System::Introspector::State; use File::Tree::Snapshot; use System::Introspector::Config; -use System::Introspector::Logger qw( :log ); +use System::Introspector::Logger qw(:log); +use Log::Contextual::Destination; +use Log::Contextual::SimpleLogger; +use Object::Remote::Logging qw( ); + GetOptions( 'c|config=s' => \my $config_file, @@ -27,18 +31,28 @@ die "Requires --config\n" die "Requires --all or --group option\n" unless $update_all or @update_groups; -#command line arguments override the logging configuration -#and --log-level overrides -d +#--log-level overrides -d if (defined($debug) && ! defined($log_level)) { - $log_level = 'DEBUG'; + $log_level = 'debug'; } -$config_file = "$storage_dir/main.conf" unless defined $config_file; +my $log_destination; +if (defined($log_level)) { +warn "$log_level"; + $log_destination = Log::Contextual::Destination->new( + logger => Log::Contextual::SimpleLogger->new({ levels_upto => $log_level }), + ); + + $log_destination->connect(System::Introspector::Logger->get_router); + #$log_destination->connect(Log::Contextual->get_root_router); + #TODO attaching to this router does't work here because of + #timming issue + #$log_destination->connect(Object::Remote::Logging->get_router); +} -my %config_args = (config_file => $config_file); -$config_args{log_level} = $log_level if defined $log_level; +$config_file = "$storage_dir/main.conf" unless defined $config_file; -my $config = System::Introspector::Config->new(%config_args); +my $config = System::Introspector::Config->new(config_file => $config_file); $config->has_group($_) or die "Unknown group '$_'\n" for @update_groups;