From: Martin J. E. <mar...@ea...> - 2011-11-01 14:13:35
|
Hi, Is this really the intended behaviour: perl -w -le 'use strict;use warnings;use Log::Log4perl qw(get_logger); my $lh = get_logger("BET::Data::Remove"); $lh->debug("fred");$lh->logwarn("warning from l:l"); warn("warning");' Log4perl: Seems like no initialization happened. Forgot to call init()? warning at -e line 1. i.e., if something does not call init for Log::Log4perl but has a log handle when logwarn is called a warn does not happen? So substituting warn with logwarn does not always warn! I spent some time debugging a problem this morning only to discover this. I find this most worrying as I'd expect the warn to happen whatever. If you substitute logdie for die it seems to work. perl -MLog::Log4perl -le 'print $Log::Log4perl::VERSION;' 1.33 This is perl, v5.10.1 (*) built for i686-linux-gnu-thread-multi Martin -- Martin J. Evans Easysoft Limited http://www.easysoft.com |
From: Mike S. <m...@pe...> - 2011-11-21 04:46:36
|
On Tue, 1 Nov 2011, Martin J. Evans wrote: > So substituting warn with logwarn does not always warn! That's an interesting case. The way it's implemented right now is that logwarn() will only call warn() (along with other log4perl actions) if the log level is greater or equal than WARN. logdie(), on the other hand, will call die() unconditionally, because it's an action, not only a message. -- -- Mike Mike Schilli m...@pe... > Hi, > > Is this really the intended behaviour: > > perl -w -le 'use strict;use warnings;use Log::Log4perl qw(get_logger); my $lh = get_logger("BET::Data::Remove"); $lh->debug("fred");$lh->logwarn("warning from l:l"); warn("warning");' > > Log4perl: Seems like no initialization happened. Forgot to call init()? > warning at -e line 1. > > i.e., if something does not call init for Log::Log4perl but has a log handle when logwarn is called a warn does not happen? > > > I spent some time debugging a problem this morning only to discover this. I find this most worrying as I'd expect the warn to happen whatever. If you substitute logdie for die it seems to work. > > perl -MLog::Log4perl -le 'print $Log::Log4perl::VERSION;' > 1.33 > This is perl, v5.10.1 (*) built for i686-linux-gnu-thread-multi > > Martin > |
From: Martin J. E. <mar...@ea...> - 2011-11-21 09:23:40
|
On 21/11/11 04:46, Mike Schilli wrote: > On Tue, 1 Nov 2011, Martin J. Evans wrote: > >> So substituting warn with logwarn does not always warn! > > That's an interesting case. The way it's implemented right now is that > logwarn() will only call warn() (along with other log4perl actions) if > the log level is greater or equal than WARN. > > logdie(), on the other hand, will call die() unconditionally, because > it's an action, not only a message. > > -- -- Mike So simply substituting warn with logwarn can change the way your program works. It is not for me to tell you how Log::Log4perl should work but I find this behaviour unacceptable as my program will behave differently depending on the log level. Logging should be logging, not changing the way my program runs. Example: $ perl -le '$SIG{__WARN__} = sub {CORE::die "Warning:\n", @_, "\n"}; use Log::Log4perl qw(get_logger); my $lh = get_logger("BET::Data::Remove");warn("fred"); print "ok";' Warning: fred at -e line 1. Change the warn to logwarn: $ perl -le '$SIG{__WARN__} = sub {CORE::die "Warning:\n", @_, "\n"}; use Log::Log4perl qw(get_logger); my $lh = get_logger("BET::Data::Remove");$lh->logwarn("fred"); print "ok"; ok Would you consider changing this? If not, I would be most grateful if you could you point me at the place where I could change this behaviour or tell my how I could override it. Martin >> Hi, >> >> Is this really the intended behaviour: >> >> perl -w -le 'use strict;use warnings;use Log::Log4perl qw(get_logger); my $lh = get_logger("BET::Data::Remove"); $lh->debug("fred");$lh->logwarn("warning from l:l"); warn("warning");' >> >> Log4perl: Seems like no initialization happened. Forgot to call init()? >> warning at -e line 1. >> >> i.e., if something does not call init for Log::Log4perl but has a log handle when logwarn is called a warn does not happen? >> > >> >> I spent some time debugging a problem this morning only to discover this. I find this most worrying as I'd expect the warn to happen whatever. If you substitute logdie for die it seems to work. >> >> perl -MLog::Log4perl -le 'print $Log::Log4perl::VERSION;' >> 1.33 >> This is perl, v5.10.1 (*) built for i686-linux-gnu-thread-multi >> >> Martin >> -- Martin J. Evans Easysoft Limited http://www.easysoft.com |
From: Mike S. <m...@pe...> - 2011-12-24 01:01:59
|
On Mon, 21 Nov 2011, Martin J. Evans wrote: > Would you consider changing this? If not, I would be most grateful if > you could you point me at the place where I could change this > behaviour or tell my how I could override it. Alright, I gave in and fixed it :) https://github.com/mschilli/log4perl/commit/7d7fbbb45254d6c903f5b3cb91d7 Thanks for bringing this to my attention. Please give it a whirl! -- -- Mike > > Martin > >>> Hi, >>> >>> Is this really the intended behaviour: >>> >>> perl -w -le 'use strict;use warnings;use Log::Log4perl qw(get_logger); my $lh = get_logger("BET::Data::Remove"); $lh->debug("fred");$lh->logwarn("warning from l:l"); warn("warning");' >>> >>> Log4perl: Seems like no initialization happened. Forgot to call init()? >>> warning at -e line 1. >>> >>> i.e., if something does not call init for Log::Log4perl but has a log handle when logwarn is called a warn does not happen? >>> >> >>> >>> I spent some time debugging a problem this morning only to discover this. I find this most worrying as I'd expect the warn to happen whatever. If you substitute logdie for die it seems to work. >>> >>> perl -MLog::Log4perl -le 'print $Log::Log4perl::VERSION;' >>> 1.33 >>> This is perl, v5.10.1 (*) built for i686-linux-gnu-thread-multi >>> >>> Martin >>> > > > -- -- Mike Mike Schilli m...@pe... |
From: Martin J. E. <mar...@ea...> - 2012-01-03 10:17:31
|
On 24/12/11 01:01, Mike Schilli wrote: > On Mon, 21 Nov 2011, Martin J. Evans wrote: > >> Would you consider changing this? If not, I would be most grateful if >> you could you point me at the place where I could change this >> behaviour or tell my how I could override it. > > Alright, I gave in and fixed it :) Excellent and thank you. > https://github.com/mschilli/log4perl/commit/7d7fbbb45254d6c903f5b3cb91d7 > > Thanks for bringing this to my attention. Please give it a whirl! I have /whirled/ it and it a) now warns when it didn't before and b) seems to still work in all other ways we are using it. Thanks again. Martin -- Martin J. Evans Easysoft Limited http://www.easysoft.com > >> >> Martin >> >>>> Hi, >>>> >>>> Is this really the intended behaviour: >>>> >>>> perl -w -le 'use strict;use warnings;use Log::Log4perl qw(get_logger); my $lh = get_logger("BET::Data::Remove"); $lh->debug("fred");$lh->logwarn("warning from l:l"); warn("warning");' >>>> >>>> Log4perl: Seems like no initialization happened. Forgot to call init()? >>>> warning at -e line 1. >>>> >>>> i.e., if something does not call init for Log::Log4perl but has a log handle when logwarn is called a warn does not happen? >>>> >>> >>>> >>>> I spent some time debugging a problem this morning only to discover this. I find this most worrying as I'd expect the warn to happen whatever. If you substitute logdie for die it seems to work. >>>> >>>> perl -MLog::Log4perl -le 'print $Log::Log4perl::VERSION;' >>>> 1.33 >>>> This is perl, v5.10.1 (*) built for i686-linux-gnu-thread-multi >>>> >>>> Martin >>>> >> >> >> > |