Closed MadLord80 closed 6 years ago
Thanks for the report! An easier solution would be to my $binmode = $self->{binmode} || ':utf8';
which I think is what the code was supposed to be. I've added the fix and released v1.705 to CPAN.
No, this is wrong
my $binmode = $self->{binmode} || ':utf8';
$binmode = ":$binmode" unless substr($binmode,0,1) eq ':';
If i set
Log::Any::Adapter->set('File', $file, binmode => 'raw');
(binmode without ':'), then binmode set incorrectly
my $binmode = $self->{binmode} || ':utf8'; # $binmode = 'raw'
$binmode = ":$binmode" unless substr($binmode,0,1) eq ':'; # condition not work, $binmode still 'raw', without ':'
Why does the condition not work?
$ perl -E'$binmode = "raw"; say substr( $binmode, 0, 1 );'
r
$ perl -E'$binmode = ":raw"; say substr( $binmode, 0, 1 );'
:
$ perl -E'$binmode = "raw"; $binmode = ":$binmode" unless substr( $binmode, 0, 1 ) eq ":"; say $binmode'
:raw
$ perl -E'$binmode = ":raw"; $binmode = ":$binmode" unless substr( $binmode, 0, 1 ) eq ":"; say $binmode'
:raw
However, notice what happens if I do not use parens:
$ perl -E'$binmode = "raw"; $binmode = ":$binmode" unless substr $binmode, 0, 1 eq ":"; say $binmode'
:raw
$ perl -E'$binmode = ":raw"; $binmode = ":$binmode" unless substr $binmode, 0, 1 eq ":"; say $binmode'
::raw
That doubles the colon, but it's still adding a colon. In none of these cases is a colon not added to $binmode
.
You're going to have to give me a failing test case that I can reproduce on my machine.
ok, sorry...i was wrong )))...
In Log::Any::Adapter::File package very strange definition:
my $binmode ||= ':utf8';
This dont work if we use (example):Log::Any::Adapter->set('File', $file, log_level => 'trace', binmode => ':raw');
Binmode remainds default (utf8).My suggestion: