use Log::Contextual qw( set_logger );
sub init_logging {
- my ($self, $level) = @_;
+ my ($self, $level, $logger) = @_;
$level = 'WARN' unless defined $level;
+ unless(defined($logger)) {
+ $logger = System::Introspector::Logger::Output->new({
+ env_prefix => 'SYSTEM_INTROSPECTOR_LOG',
+ });
+ }
#TODO: better way to specify log level?
$ENV{SYSTEM_INTROSPECTOR_LOG_UPTO} = $level;
- set_logger(System::Introspector::Logger::Output->new({
- env_prefix => 'SYSTEM_INTROSPECTOR_LOG',
- }));
+ set_logger($logger);
}
-#require this in the test to initialize the logging framewor
+#require this file in the test to initialize the logging framework
#so the tests can run
-use System::Introspector::Logger qw( );
-System::Introspector::Logger->init_logging('WARN');
-1;
\ No newline at end of file
+
+package System::Introspector::Logger::TestOutput;
+
+use Log::Contextual::WarnLogger;
+use base qw ( Log::Contextual::SimpleLogger );
+#
+#we want the code blocks in the log lines to execute but not
+#output anything so turn this into a null logger
+sub _log { }
+
+package main;
+
+use System::Introspector::Logger qw();
+#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',
+ System::Introspector::Logger::TestOutput->new({
+ levels_upto => 'trace'
+ }),
+);
+
+1;
+