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 };
}