preaction / Log-Any

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

default_adapter option does not behave as expected #65

Closed dallaylaen closed 6 years ago

dallaylaen commented 6 years ago

I've tried using the default_adapter option according to the documentation and it doesn't do what I expect it to. The following is a minimal isolated example:

 perl -we 'use Log::Any q{$log}, default_adapter => "Stderr"; $log->err("Foobared");'

Expected result: a message mentioning Foobared.

Actual result: Empty.

What am I doing wrong?

mephinet commented 6 years ago

This reminds me of the issue I had when first implementing the $LOG_ANY_DEFAULT_ADAPTER environment variable, and that I fixed with 3d5ee5cfc5f91e26d865288547972b8372bdb219. In your case, too, $log is an instance of Log::Any::Proxy::Null - which is not correct. Fortunately for me, the issue is still present when I test it with Log::Any version 1.049, so I'm not to blame. phew

mephinet commented 6 years ago

I guess the issue here is that Log::Any::get_logger first calls _get_proxy_class (when has_consumer is still false, resulting in the Null proxy) and only then processes the default_adapter parameter. If the order is changed, your example code works...

dallaylaen commented 6 years ago

Oh, so it's actually a bug and not me misreading the doc?

Submitted #66 then.

preaction commented 6 years ago

Fixed by #66

preaction commented 6 years ago

Released in v1.702