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: 87133
Status: resolved
Priority: 0/
Queue: Log-Dispatch

People
Owner: Nobody in particular
Requestors: ross.attrill [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 2.40
Fixed in: 2.41



Subject: Difficult to find source if level not provided
If the user fails to provide a level then it can be very hard to work out which line of user's source this has been caused in as Log::Dispatch doesn't handle this. For example user types $log->log(message); they will get a hash element undefined warning (which becomes fatal in some contexts like Dancer) giving the location in Log/Dispatch.pm but not the source line causing the problem. This can become very hard to track down. A small change to the sub level_is_valid to introduce 'croak' should fix this: use Carp qw(croak); ... sub level_is_valid { shift; my $level = shift; croak "Logging level not provided" unless $level; return $LEVELS{ $level }; }
From: ross.attrill [...] gmail.com
On Mon Jul 22 00:09:58 2013, uvb wrote: Show quoted text
> If the user fails to provide a level then it can be very hard to work > out which line of user's source this has been caused in as > Log::Dispatch doesn't handle this. > > For example user types > > $log->log(message); > > they will get a hash element undefined warning (which becomes fatal in > some contexts like Dancer) giving the location in Log/Dispatch.pm > but not the source line causing the problem. This can become very > hard to track down. > > A small change to the sub level_is_valid to introduce 'croak' should > fix this: > > > sub level_is_valid { > shift; > my $level = shift; > Carp::croak("Logging level not provided") unless $level; > return $LEVELS{ $level }; > } >
See Pull Request: https://github.com/autarch/Log-Dispatch/pull/3