From: Tyler Riddle Date: Wed, 5 Dec 2012 21:43:21 +0000 (-0800) Subject: remove t/logsetup.pl and move feature into $ENV{OBJECT_REMOTE_TEST_LOGGER}; set to... X-Git-Tag: v0.003001_01~44 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=abef6e5b046572e5130c41ce62d7dde01978562f;p=scpubgit%2FObject-Remote.git remove t/logsetup.pl and move feature into $ENV{OBJECT_REMOTE_TEST_LOGGER}; set to 1 to enable testing of all log code --- diff --git a/lib/Object/Remote/Logging.pm b/lib/Object/Remote/Logging.pm index 8646c82..58ccfb0 100644 --- a/lib/Object/Remote/Logging.pm +++ b/lib/Object/Remote/Logging.pm @@ -70,11 +70,20 @@ sub init_logging { my $level = $ENV{OBJECT_REMOTE_LOG_LEVEL}; my $format = $ENV{OBJECT_REMOTE_LOG_FORMAT}; my $selections = $ENV{OBJECT_REMOTE_LOG_SELECTIONS}; + my $test_logging = $ENV{OBJECT_REMOTE_TEST_LOGGER}; my %controller_should_log; unless (defined $ENV{OBJECT_REMOTE_LOG_FORWARDING} && $ENV{OBJECT_REMOTE_LOG_FORWARDING} ne '') { $ENV{OBJECT_REMOTE_LOG_FORWARDING} = 1; } + + if ($test_logging) { + require Object::Remote::Logging::TestLogger; + router->connect(Object::Remote::Logging::TestOutput->new( + min_level => 'trace', max_level => 'error', + level_names => Object::Remote::Logging->arg_levels(), + )); + } return unless defined $level && $level ne ''; $format = "[%l %r] %s" unless defined $format; diff --git a/lib/Object/Remote/Logging/TestLogger.pm b/lib/Object/Remote/Logging/TestLogger.pm new file mode 100644 index 0000000..5d94224 --- /dev/null +++ b/lib/Object/Remote/Logging/TestLogger.pm @@ -0,0 +1,8 @@ +package Object::Remote::Logging::TestOutput; + +use base qw ( Object::Remote::Logging::Logger ); + +#don't need to output anything +sub _output { } + +1; diff --git a/t/await.t b/t/await.t index c846637..0ab2803 100644 --- a/t/await.t +++ b/t/await.t @@ -3,7 +3,7 @@ use Test::More; use Test::Fatal; use FindBin; use lib "$FindBin::Bin/lib"; -require 't/logsetup.pl'; +$ENV{OBJECT_REMOTE_TEST_LOGGER} = 1; use Object::Remote; use Object::Remote::Future qw( await_all await_future ); diff --git a/t/basic.t b/t/basic.t index b8fee8e..329f606 100644 --- a/t/basic.t +++ b/t/basic.t @@ -2,7 +2,7 @@ use strictures 1; use Test::More; use Sys::Hostname qw(hostname); -require 't/logsetup.pl'; +$ENV{OBJECT_REMOTE_TEST_LOGGER} = 1; use Object::Remote; diff --git a/t/basic_data.t b/t/basic_data.t index e41ba55..c0f960e 100644 --- a/t/basic_data.t +++ b/t/basic_data.t @@ -2,7 +2,7 @@ use strictures 1; use Test::More; use Sys::Hostname qw(hostname); -require 't/logsetup.pl'; +$ENV{OBJECT_REMOTE_TEST_LOGGER} = 1; use Object::Remote::FromData; diff --git a/t/bridged.t b/t/bridged.t index 2a092b8..b8697b2 100644 --- a/t/bridged.t +++ b/t/bridged.t @@ -5,7 +5,7 @@ use FindBin; use lib "$FindBin::Bin/lib"; -require 't/logsetup.pl'; +$ENV{OBJECT_REMOTE_TEST_LOGGER} = 1; use Object::Remote; diff --git a/t/perl_execute.t b/t/perl_execute.t index e92db59..e2ccace 100644 --- a/t/perl_execute.t +++ b/t/perl_execute.t @@ -3,7 +3,7 @@ use Test::More; use Data::Dumper; -require 't/logsetup.pl'; +$ENV{OBJECT_REMOTE_TEST_LOGGER} = 1; use Object::Remote::Connector::Local; use Object::Remote::Connector::SSH; diff --git a/t/reconnect.t b/t/reconnect.t index 2b5473b..4d99de2 100644 --- a/t/reconnect.t +++ b/t/reconnect.t @@ -1,6 +1,8 @@ use strictures 1; use Test::More; +$ENV{OBJECT_REMOTE_TEST_LOGGER} = 1; + use Object::Remote; use Object::Remote::FromData; @@ -39,4 +41,4 @@ sub pid { sub ping { return 'pong'; -} \ No newline at end of file +} diff --git a/t/sender.t b/t/sender.t index cd9c681..6d50e50 100644 --- a/t/sender.t +++ b/t/sender.t @@ -1,7 +1,7 @@ use strictures 1; use Test::More; -require 't/logsetup.pl'; +$ENV{OBJECT_REMOTE_TEST_LOGGER} = 1; use Object::Remote::Connector::Local; use Object::Remote; diff --git a/t/start_core.t b/t/start_core.t index 964a103..b50b9f3 100644 --- a/t/start_core.t +++ b/t/start_core.t @@ -3,7 +3,7 @@ use Test::More; use Object::Remote; use File::Spec; -require 't/logsetup.pl'; +$ENV{OBJECT_REMOTE_TEST_LOGGER} = 1; { package S1S; diff --git a/t/tied.t b/t/tied.t index e22ee2e..0cca142 100644 --- a/t/tied.t +++ b/t/tied.t @@ -6,7 +6,7 @@ use lib 't/lib'; use Tie::Array; use Tie::Hash; -require 't/logsetup.pl'; +$ENV{OBJECT_REMOTE_TEST_LOGGER} = 1; use Object::Remote; use ORTestTiedRemote; diff --git a/t/timeout.t b/t/timeout.t index 3b208d7..46b46fe 100644 --- a/t/timeout.t +++ b/t/timeout.t @@ -1,7 +1,7 @@ use strictures 1; use Test::More; -require 't/logsetup.pl'; +$ENV{OBJECT_REMOTE_TEST_LOGGER} = 1; use Object::Remote; use Object::Remote::Connector::Local; diff --git a/t/transfer.t b/t/transfer.t index 1102194..ad426ad 100644 --- a/t/transfer.t +++ b/t/transfer.t @@ -3,7 +3,7 @@ use Test::More; use Test::Fatal; use FindBin; -require 't/logsetup.pl'; +$ENV{OBJECT_REMOTE_TEST_LOGGER} = 1; $ENV{PERL5LIB} = join( ':', ($ENV{PERL5LIB} ? $ENV{PERL5LIB} : ()), qw(lib t/lib) diff --git a/t/watchdog_fatnode.t b/t/watchdog_fatnode.t index ee954f0..2b73ce6 100644 --- a/t/watchdog_fatnode.t +++ b/t/watchdog_fatnode.t @@ -1,7 +1,7 @@ use strictures 1; use Test::More; -require 't/logsetup.pl'; +$ENV{OBJECT_REMOTE_TEST_LOGGER} = 1; use Object::Remote::Connector::Local;