Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Log-Dispatch CPAN distribution.

Report information
The Basics
Id: 44821
Status: resolved
Priority: 0/
Queue: Log-Dispatch

People
Owner: Nobody in particular
Requestors: dmartin [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 2.23



Subject: Patch to add 'warn' as valid log level
Date: Mon, 6 Apr 2009 08:55:39 -0700
To: bug-log-dispatch [...] rt.cpan.org
From: Dylan Martin <dmartin [...] cpan.org>
This patch adds 'warn' as a valid abbreviation for 'warning'. I've updated tests and docs to reflect the addition. I was using Authen::Simple in Catalyst and Log::Dispatch as my logger. Authen::Simple requires a logging object which provides 'debug','info','warn' and 'error', and 'warn' was the only method missing from Log::Dispatch. I hope you like it. Let me know if you have any questions. -Dylan diff -r -u -b Log-Dispatch-2.22-JJHr0m/lib/Log/Dispatch/Output.pm Log-Dispatch-2.22-hLzc63/lib/Log/Dispatch/Output.pm --- Log-Dispatch-2.22-JJHr0m/lib/Log/Dispatch/Output.pm 2008-11-11 10:31:11.000000000 -0800 +++ Log-Dispatch-2.22-hLzc63/lib/Log/Dispatch/Output.pm 2009-04-06 08:28:15.000000000 -0700 @@ -56,6 +56,7 @@ my $x = 0; $self->{level_numbers} = { ( map { $_ => $x++ } @{ $self->{level_names} } ), + warn => 3, err => 4, crit => 5, emerg => 7 }; diff -r -u -b Log-Dispatch-2.22-JJHr0m/lib/Log/Dispatch.pm Log-Dispatch-2.22-hLzc63/lib/Log/Dispatch.pm --- Log-Dispatch-2.22-JJHr0m/lib/Log/Dispatch.pm 2008-11-11 10:31:11.000000000 -0800 +++ Log-Dispatch-2.22-hLzc63/lib/Log/Dispatch.pm 2009-04-06 08:38:27.000000000 -0700 @@ -15,7 +15,7 @@ BEGIN { - foreach my $l ( qw( debug info notice warning err error crit critical alert emerg emergency ) ) + foreach my $l ( qw( debug info notice warn warning err error crit critical alert emerg emergency ) ) { my $sub = sub { my $self = shift; $self->log( level => $l, message => "@_" ); }; @@ -382,8 +382,8 @@ =back Alternately, the numbers 0 through 7 may be used (debug is 0 and -emergency is 7). The syslog standard of 'err', 'crit', and 'emerg' -is also acceptable. +emergency is 7). The abbreviations 'warn', 'err', 'crit', and 'emerg' +are also acceptable. =head1 USAGE Only in Log-Dispatch-2.22-hLzc63: Makefile.old diff -r -u -b Log-Dispatch-2.22-JJHr0m/t/01-basic.t Log-Dispatch-2.22-hLzc63/t/01-basic.t --- Log-Dispatch-2.22-JJHr0m/t/01-basic.t 2008-11-11 10:31:11.000000000 -0800 +++ Log-Dispatch-2.22-hLzc63/t/01-basic.t 2009-04-06 08:39:08.000000000 -0700 @@ -1,7 +1,7 @@ use strict; use warnings; -use Test::More tests => 146; +use Test::More tests => 155; use File::Spec; use File::Temp qw( tempdir ); @@ -336,7 +336,7 @@ # Comprehensive test of new methods that match level names { my %levels = map { $_ => $_ } ( qw( debug info notice warning error critical alert emergency ) ); - @levels{ qw( err crit emerg ) } = ( qw( error critical emergency ) ); + @levels{ qw( warn err crit emerg ) } = ( qw( warning error critical emergency ) ); foreach my $allowed_level ( qw( debug info notice warning error critical alert emergency ) ) { @@ -349,7 +349,7 @@ max_level => $allowed_level, ) ); - foreach my $test_level ( qw( debug info notice warning err + foreach my $test_level ( qw( debug info notice warn warning err error crit critical alert emerg emergency ) ) { $string = ''; @@ -372,7 +372,7 @@ # Log::Dispatch->level_is_valid method { - foreach my $l ( qw( debug info notice warning err error + foreach my $l ( qw( debug info notice warn warning err error crit critical alert emerg emergency ) ) { ok( Log::Dispatch->level_is_valid($l), "$l is valid level" );