preaction / Log-Any

Simple, fast Perl logging API compatible with any logging system
Other
13 stars 19 forks source link

Log levels detection for Stderr, Stdout, etc.. #55

Closed 0x62ash closed 7 years ago

0x62ash commented 7 years ago

Hello, Looks like Log::Any doesn't detect WARN log level because LOG_LEVEL_ALIASES in lower case and matching is case-sensitive.

And I think that if detection is failed then adapter should choose default log level, instead of producing Use of uninitialized value in numeric le (<=) at /Users/bash/Workshop/perl5/lib/perl5/Log/Any/Adapter/Stderr.pm line 44.

preaction commented 7 years ago

I don't really like the idea of silently absorbing an obvious error condition. So, I think we could do two things:

1) [x] Run all log level aliases through lc. All the regular log levels work with any kind of casing, so we should accept all log level aliases with any case as well. 2) [x] If we can't determine the numeric log level inside the Adapter, send a specific warn message detailing the problem (using Perl's warn and $log->warn) and default to the original default (for Stderr, Stdout, File, and Syslog it is "trace").

If we do both of these things, it should prevent logging messages getting lost and still alert people that their wishes aren't being honored for a reason.

Would this solve your problem?

0x62ash commented 7 years ago

Absolutely agree

preaction commented 7 years ago

This is finally released to CPAN as a stable 1.048 release. Thanks for the help!