From: Arthur Axel 'fREW' Schmidt Date: Sat, 3 Nov 2012 06:24:12 +0000 (-0500) Subject: lazily load default router X-Git-Tag: v0.005000_01~13 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0092c26ae50490d5a24fa003a41c8d082e87de27;p=p5sagit%2FLog-Contextual.git lazily load default router --- diff --git a/lib/Log/Contextual.pm b/lib/Log/Contextual.pm index 70348b6..7580cac 100644 --- a/lib/Log/Contextual.pm +++ b/lib/Log/Contextual.pm @@ -11,7 +11,6 @@ use Exporter::Declare; use Exporter::Declare::Export::Generator; use Data::Dumper::Concise; use Scalar::Util 'blessed'; -use Log::Contextual::Router; my @dlog = ((map "Dlog_$_", @levels), (map "DlogS_$_", @levels)); @@ -36,7 +35,14 @@ export_tag dlog => ('____'); export_tag log => ('____'); import_arguments qw(logger package_logger default_logger); -sub arg_router { return $_[1] if defined $_[1]; our $Router_Instance ||= Log::Contextual::Router->new } +sub arg_router { + return $_[1] if defined $_[1]; + our $Router_Instance ||= do { + require Log::Contextual::Router; + Log::Contextual::Router->new + } +} + sub arg_logger { $_[1] } sub arg_levels { $_[1] || [qw(debug trace warn info error fatal)] } sub arg_package_logger { $_[1] }