This is kind of annoying thing that I noticed recently, if you do
$logger->info($msg) and $msg is
undefined then you get a warning:
perl -W -Ilib -e 'use Log::Log4perl qw(:easy);
Log::Log4perl->easy_init($INFO); INFO(undef)'
Use of uninitialized value in join or string at lib/Log/Log4perl/Appender.pm
line 167.
and it's not even a very helpful warning since it's buried in the guts of
Log4perl.
Using git bisect (neat tool) I found while I (myself even!) had fixed the issue
back in
029d7df8 in 2002, I broke it (me again!) in afb95ef7e in 2003.
Anyway, this would be the correct fix for it now, if all we're going to do is
make a
string out of it, it's ok just to use the defined bits of the mssage.
Any opinion on this? Or should we stay with the uninitialized warning, however
unhelpful it is?
diff --git a/lib/Log/Log4perl/Appender.pm b/lib/Log/Log4perl/Appender.pm
index 923836f..455fd09 100644
--- a/lib/Log/Log4perl/Appender.pm
+++ b/lib/Log/Log4perl/Appender.pm
@@ -162,10 +162,13 @@ sub log {
#not defined, the normal case
if (! defined $self->{warp_message} ){
#join any message elements
- $p->{message} =
- join($Log::Log4perl::JOIN_MSG_ARRAY_CHAR,
- @{$p->{message}}
- ) if ref $p->{message} eq "ARRAY";
+ if (ref $p->{message} eq "ARRAY"){
+ $p->{message} =
+ join($Log::Log4perl::JOIN_MSG_ARRAY_CHAR,
+ grep { defined $_ }
+ @{$p->{message}}
+ );
+ }
#defined but false, e.g. Appender::DBI
} elsif (! $self->{warp_message}) {
If nobody objects I can make a unit test for it as well and push it to Mike via
github.
--
Kevin G.
------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
log4perl-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/log4perl-devel