You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now, the default Log::Any::Proxy tries to return the formatted message so that the user can use that to send a warn or die with an exception. The proxy also has boolean methods for determining if the given log level is currently activated (like is_warn and is_debug). But there are a few cases where the proxy uses a bare return, which can cause problems if the user is expecting a scalar (either a log message, or a boolean).
This may be contrived, but if the user does something like this:
my %data = (
foo => $LOG->infof( $got_foo ),
bar => $LOG->infof( $got_bar ),
);
and both $got_foo and $got_bar are undefined, then %data will end up being foo => "bar", which is absolutely not what the user expected.
Then if the user also uses $LOG->is_debug to see if the app is in debug mode, they will end up with an odd number of elements in their hash when it is not in debug mode.
Right now, the default Log::Any::Proxy tries to return the formatted message so that the user can use that to send a
warn
ordie
with an exception. The proxy also has boolean methods for determining if the given log level is currently activated (likeis_warn
andis_debug
). But there are a few cases where the proxy uses a barereturn
, which can cause problems if the user is expecting a scalar (either a log message, or a boolean).This may be contrived, but if the user does something like this:
and both
$got_foo
and$got_bar
are undefined, then%data
will end up beingfoo => "bar"
, which is absolutely not what the user expected.Then if the user also uses
$LOG->is_debug
to see if the app is in debug mode, they will end up with an odd number of elements in their hash when it is not in debug mode.In theory this means enforcing booleanness on https://metacpan.org/source/PREACTION/Log-Any-1.045/lib/Log/Any/Proxy.pm#L75 to isolate the user from problems in the adapter, and returning
undef
at the two bare returns in this method: https://metacpan.org/source/PREACTION/Log-Any-1.045/lib/Log/Any/Proxy.pm#L92-97All of these methods should return a scalar explicitly. This is an API change (hooray), so we'll have to warn people we're doing it.
The text was updated successfully, but these errors were encountered: