From: Tyler Riddle Date: Thu, 8 Nov 2012 19:27:28 +0000 (-0800) Subject: set defaults for min and max levels in various loggers X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b83e492244be8ab1419c38267f94bb6f56e95b58;p=scpubgit%2FObject-Remote.git set defaults for min and max levels in various loggers --- diff --git a/lib/Object/Remote/Logging/DieLogger.pm b/lib/Object/Remote/Logging/DieLogger.pm new file mode 100644 index 0000000..a3f7aa8 --- /dev/null +++ b/lib/Object/Remote/Logging/DieLogger.pm @@ -0,0 +1,13 @@ +package Object::Remote::Logging::DieLogger; + +use Moo; + +extends 'Object::Remote::Logging::Logger'; + +has format => ( is => 'ro', required => 1, default => sub { '%s at %f line %i' } ); +has max_level => ( is => 'ro', required => 1, default => sub { 'fatal' } ); +has min_level => ( is => 'ro', required => 1, default => sub { 'fatal' } ); + +sub output { die $_[1] }; + +1; diff --git a/lib/Object/Remote/Logging/Logger.pm b/lib/Object/Remote/Logging/Logger.pm index e440d57..888d998 100644 --- a/lib/Object/Remote/Logging/Logger.pm +++ b/lib/Object/Remote/Logging/Logger.pm @@ -6,7 +6,7 @@ use Scalar::Util qw(weaken); has format => ( is => 'ro', required => 1, default => sub { '%l: %s' } ); has level_names => ( is => 'ro', required => 1 ); has min_level => ( is => 'ro', required => 1 ); -has max_level => ( is => 'ro' ); +has max_level => ( is => 'ro', required => 1, deafult => sub { 'info' } ); has _level_active => ( is => 'lazy' ); sub BUILD { diff --git a/lib/Object/Remote/Logging/WarnLogger.pm b/lib/Object/Remote/Logging/WarnLogger.pm index f9ffc92..431df4a 100644 --- a/lib/Object/Remote/Logging/WarnLogger.pm +++ b/lib/Object/Remote/Logging/WarnLogger.pm @@ -5,6 +5,7 @@ use Moo; extends 'Object::Remote::Logging::Logger'; has format => ( is => 'ro', required => 1, default => sub { '%s at %f line %i, log level: %l' } ); +has max_level => ( is => 'ro', required => 1, default => sub { 'error' } ); has min_level => ( is => 'ro', required => 1, default => sub { 'warn' } ); sub output { warn $_[1] };