has config_file => (is => 'ro', required => 1);
-has log_level => (is => 'lazy');
+#TODO pull these out
+#has log_level => (is => 'lazy');
sub _build_config {
my ($self) = @_;
return \%config;
}
-sub _build_log_level {
- return $_[0]->config->{log_level};
-}
+#sub _build_log_level {
+# return $_[0]->config->{log_level};
+#}
sub sudo_user { $_[0]->config->{sudo_user} }
#where logging has not been initialized yet so
#it must be initialized again before the probe can
#run
-sub init_logging {
- my ($self, $log_level, $context) = @_;
- System::Introspector::Logger->init_logging($log_level, $context);
- return $self;
-}
+#TODO waiting to see if this really is never coming back
+#sub init_logging {
+# my ($self, $log_level, $context) = @_;
+# System::Introspector::Logger->init_logging($context);
+# return $self;
+#}
sub gather_all {
my ($self) = @_;
use base qw(Log::Contextual);
use System::Introspector::Logger::Output;
-use Log::Contextual qw( set_logger );
+use Log::Contextual qw( :log );
+use Log::Contextual::Destination;
+
+sub arg_router { $_[1] || Log::Contextual::Router::Dynamic->new }
#should always pass in log level and execution context;
#specifying a logger is used when logging during
#testing so a null output logging class can be used
-sub init_logging {
- my ($self, $level, $context, $logger) = @_;
-
- $level = 'WARN' unless defined $level;
- unless(defined($logger)) {
- $logger = System::Introspector::Logger::Output->new({
- env_prefix => 'SYSTEM_INTROSPECTOR_LOG',
- });
-
- $logger->set_execution_context($context);
- }
-
- #TODO: better way to specify log level?
- $ENV{SYSTEM_INTROSPECTOR_LOG_UPTO} = $level;
-
- set_logger($logger);
-
- return 1;
-}
+#TODO waiting to see if this really is never coming back
+#sub init_logging {
+# my ($self, $level, $context, $output) = @_;
+#
+# $level = 'WARN' unless defined $level;
+# #TODO: better way to specify log level?
+# $ENV{SYSTEM_INTROSPECTOR_LOG_UPTO} = $level;
+#
+# unless(defined($output)) {
+# $output = System::Introspector::Logger::Output->new({
+# env_prefix => 'SYSTEM_INTROSPECTOR_LOG',
+# });
+#
+# $output->set_execution_context($context);
+# }
+#
+# my $dest = Log::Contextual::Destination->new(logger => $output);
+# $dest->connect($self->get_router);
+#
+# return 1;
+#}
1;
\ No newline at end of file
-use strictures 1;
-
package System::Introspector::Logger::Output;
-use Log::Contextual::WarnLogger;
-use base qw ( Log::Contextual::WarnLogger );
+use strictures 1;
+
+#using simple logger because the configuration
+#interface is slightly nicer
+use Log::Contextual::SimpleLogger;
+use base qw ( Log::Contextual::SimpleLogger );
sub set_execution_context {
my ($self, $context_name) = @_;
($1, $2);
} @fields };
}
- Dlog_trace { "Completed gathering open file information: $_" } @handles;
+ log_trace { "Completed gathering open file information" };
return { handles => \@handles };
};
}
sub sudo_user { $_[0]->config->sudo_user }
-sub BUILD {
- my ($self) = @_;
- System::Introspector::Logger->init_logging($self->config->log_level, 'controller');
-}
+#TODO waiting to see if this really is never coming back
+#sub BUILD {
+# my ($self) = @_;
+# System::Introspector::Logger->init_logging('controller');
+#}
sub gather {
my ($self, @groups) = @_;
host => $arg{host},
sudo_user => $arg{sudo} && $self->sudo_user,
introspectors => $arg{introspectors},
- )->init_logging($self->config->log_level, "probe:$arg{host}");
+ #TODO waiting to see if this really is never coming back
+ );#->init_logging($self->config->log_level, "probe:$arg{host}");
}
1;
use System::Introspector::Logger qw ( :log );
-ok (System::Introspector::Logger->init_logging('TRACE', 'testing logging system'), 'initialize logging');
+ok (System::Introspector::Logger->get_router->does('Log::Contextual::Role::Router'), 'router exists');
done_testing;
\ No newline at end of file
package main;
-use System::Introspector::Logger qw();
+use System::Introspector::Logger qw( :log );
#make sure to enable execution of every logging code block
#by setting the log level as high as it can go
-System::Introspector::Logger->init_logging('TRACE', 'test',
- System::Introspector::Logger::TestOutput->new({
- levels_upto => 'trace'
- }),
-);
+ my $____LOG_DESTINATION = Log::Contextual::Destination->new(
+ logger => System::Introspector::Logger::TestOutput->new({ levels_upto => 'trace' }),
+ );
+
+ $____LOG_DESTINATION->connect(System::Introspector::Logger->get_root_router);
1;