Skip Menu |
 

This queue is for tickets about the Log-Log4perl CPAN distribution.

Report information
The Basics
Id: 32942
Status: resolved
Priority: 0/
Queue: Log-Log4perl

People
Owner: Nobody in particular
Requestors: ostmann [...] websuche.de
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Log::Log4perl
Date: Tue, 05 Feb 2008 14:35:48 +0100
To: bug-Log-Log4perl [...] rt.cpan.org
From: Felix Antonius Wilhelm Ostmann <ostmann [...] websuche.de>
Download (untitled) / with headers
text/plain 1.9k
Log::Log4perl: 1.14 perl: v5.8.8 uname: Linux www1 2.6.17-2-686 #1 SMP Wed Sep 13 16:34:10 UTC 2006 i686 GNU/Linux i have a problem when i subclass the Log::Log4perl $other_class->get_logger($category) wont work for other classes then the __PACKAGE__ } elsif($class ne __PACKAGE__) { # Called as ::get_logger($category) this is wrong $other_class->get_logger($category) result in $class ne __PACKAGE__ this will fix that, but i dont know, perhaps other things will be broken then: } elsif($class ne __PACKAGE__ and !defined $args[0]) { # Called as ::get_logger($category) ################################################## sub get_logger { # Get an instance (shortcut) ################################################## my($class, @args) = @_; if(!defined $class) { # Called as ::get_logger() unshift(@args, scalar caller()); } elsif($class eq __PACKAGE__ and !defined $args[0]) { # Called as ->get_logger() unshift(@args, scalar caller()); # FIXME } elsif($class ne __PACKAGE__) { # Called as ::get_logger($category) # FIXME unshift(@args, $class); } else { # Called as ->get_logger($category) } # Delegate this to the logger module return Log::Log4perl::Logger->get_logger(@args); } -- Mit freundlichen Grüßen Felix Antonius Wilhelm Ostmann -------------------------------------------------- Websuche Search Technology GmbH & Co. KG Martinistraße 3 - D-49080 Osnabrück - Germany Tel.: +49 541 40666-0 - Fax: +49 541 40666-22 Email: info@websuche.de - Website: www.websuche.de -------------------------------------------------- AG Osnabrück - HRA 200252 - Ust-Ident: DE814737310 Komplementärin: Websuche Search Technology Verwaltungs GmbH - AG Osnabrück - HRB 200359 Geschäftsführer: Diplom Kaufmann Martin Steinkamp --------------------------------------------------
Subject: Re: [rt.cpan.org #32942] AutoReply: Log::Log4perl
Date: Tue, 05 Feb 2008 15:17:06 +0100
To: bug-Log-Log4perl [...] rt.cpan.org
From: Felix Antonius Wilhelm Ostmann <ostmann [...] websuche.de>
Download (untitled) / with headers
text/plain 3.1k
btw. this would be a nice more magic in the function get_logger: ref($args[0]) and $args[0] = ref($args[0]); # Delegate this to the logger module return Log::Log4perl::Logger->get_logger(@args); } so you can make sub new { ... $self->log->info("initialized"); ... } *log = \&Log::Log4perl::get_logger; Bugs in Log-Log4perl via RT schrieb: Show quoted text
> Greetings, > > This message has been automatically generated in response to the > creation of a trouble ticket regarding: > "Log::Log4perl", > a summary of which appears below. > > There is no need to reply to this message right now. Your ticket has been > assigned an ID of [rt.cpan.org #32942]. Your ticket is accessible > on the web at: > > http://rt.cpan.org/Ticket/Display.html?id=32942 > > Please include the string: > > [rt.cpan.org #32942] > > in the subject line of all future correspondence about this issue. To do so, > you may reply to this message. > > Thank you, > bug-Log-Log4perl@rt.cpan.org > > ------------------------------------------------------------------------- > Log::Log4perl: 1.14 > perl: v5.8.8 > uname: Linux www1 2.6.17-2-686 #1 SMP Wed Sep 13 16:34:10 UTC 2006 i686 > GNU/Linux > > > i have a problem when i subclass the Log::Log4perl > > $other_class->get_logger($category) wont work for other classes then the > __PACKAGE__ > > > } elsif($class ne __PACKAGE__) { > # Called as ::get_logger($category) > > this is wrong > > $other_class->get_logger($category) result in $class ne __PACKAGE__ > > > this will fix that, but i dont know, perhaps other things will be broken > then: > } elsif($class ne __PACKAGE__ and !defined $args[0]) { > # Called as ::get_logger($category) > > > > ################################################## > sub get_logger { # Get an instance (shortcut) > ################################################## > my($class, @args) = @_; > > if(!defined $class) { > # Called as ::get_logger() > unshift(@args, scalar caller()); > } elsif($class eq __PACKAGE__ and !defined $args[0]) { > # Called as ->get_logger() > unshift(@args, scalar caller()); > > # FIXME > } elsif($class ne __PACKAGE__) { > # Called as ::get_logger($category) > # FIXME > > unshift(@args, $class); > } else { > # Called as ->get_logger($category) > } > > # Delegate this to the logger module > return Log::Log4perl::Logger->get_logger(@args); > } > > > > > >
-- Mit freundlichen Grüßen Felix Antonius Wilhelm Ostmann -------------------------------------------------- Websuche Search Technology GmbH & Co. KG Martinistraße 3 - D-49080 Osnabrück - Germany Tel.: +49 541 40666-0 - Fax: +49 541 40666-22 Email: info@websuche.de - Website: www.websuche.de -------------------------------------------------- AG Osnabrück - HRA 200252 - Ust-Ident: DE814737310 Komplementärin: Websuche Search Technology Verwaltungs GmbH - AG Osnabrück - HRB 200359 Geschäftsführer: Diplom Kaufmann Martin Steinkamp --------------------------------------------------
Subject: Re: [rt.cpan.org #32942] AutoReply: Log::Log4perl
Date: Tue, 05 Feb 2008 15:33:34 +0100
To: bug-Log-Log4perl [...] rt.cpan.org
From: Felix Antonius Wilhelm Ostmann <ostmann [...] websuche.de>
Download (untitled) / with headers
text/plain 3.3k
sorry, i hate that, but i rewrite the sub get_logger and think that fix all and work faster: sub get_logger { if(@_>=2) { # Called as ->get_logger($category) return Log::Log4perl::Logger->get_logger($_[1]); } elsif(@_==0 or @_==1 && $_[0] eq __PACKAGE__) { # Called as ::get_logger() or __PACKAGE__->get_logger() return Log::Log4perl::Logger->get_logger(scalar caller()); } else { # Called as $other_class->get_logger() or ::get_logger($category) return Log::Log4perl::Logger->get_logger(ref($_[0])||$_[0]); } } Bugs in Log-Log4perl via RT schrieb: Show quoted text
> Greetings, > > This message has been automatically generated in response to the > creation of a trouble ticket regarding: > "Log::Log4perl", > a summary of which appears below. > > There is no need to reply to this message right now. Your ticket has been > assigned an ID of [rt.cpan.org #32942]. Your ticket is accessible > on the web at: > > http://rt.cpan.org/Ticket/Display.html?id=32942 > > Please include the string: > > [rt.cpan.org #32942] > > in the subject line of all future correspondence about this issue. To do so, > you may reply to this message. > > Thank you, > bug-Log-Log4perl@rt.cpan.org > > ------------------------------------------------------------------------- > Log::Log4perl: 1.14 > perl: v5.8.8 > uname: Linux www1 2.6.17-2-686 #1 SMP Wed Sep 13 16:34:10 UTC 2006 i686 > GNU/Linux > > > i have a problem when i subclass the Log::Log4perl > > $other_class->get_logger($category) wont work for other classes then the > __PACKAGE__ > > > } elsif($class ne __PACKAGE__) { > # Called as ::get_logger($category) > > this is wrong > > $other_class->get_logger($category) result in $class ne __PACKAGE__ > > > this will fix that, but i dont know, perhaps other things will be broken > then: > } elsif($class ne __PACKAGE__ and !defined $args[0]) { > # Called as ::get_logger($category) > > > > ################################################## > sub get_logger { # Get an instance (shortcut) > ################################################## > my($class, @args) = @_; > > if(!defined $class) { > # Called as ::get_logger() > unshift(@args, scalar caller()); > } elsif($class eq __PACKAGE__ and !defined $args[0]) { > # Called as ->get_logger() > unshift(@args, scalar caller()); > > # FIXME > } elsif($class ne __PACKAGE__) { > # Called as ::get_logger($category) > # FIXME > > unshift(@args, $class); > } else { > # Called as ->get_logger($category) > } > > # Delegate this to the logger module > return Log::Log4perl::Logger->get_logger(@args); > } > > > > > >
-- Mit freundlichen Grüßen Felix Antonius Wilhelm Ostmann -------------------------------------------------- Websuche Search Technology GmbH & Co. KG Martinistraße 3 - D-49080 Osnabrück - Germany Tel.: +49 541 40666-0 - Fax: +49 541 40666-22 Email: info@websuche.de - Website: www.websuche.de -------------------------------------------------- AG Osnabrück - HRA 200252 - Ust-Ident: DE814737310 Komplementärin: Websuche Search Technology Verwaltungs GmbH - AG Osnabrück - HRB 200359 Geschäftsführer: Diplom Kaufmann Martin Steinkamp --------------------------------------------------
From: MSCHILLI [...] cpan.org
Download (untitled) / with headers
text/plain 1009b
Yeah, this was a bug in Log4perl, I've just fixed it in CVS, it will be released with 1.15. One caveat is that Log4perl can't tell apart Log::Log4perl::get_logger($cat); and L4pSubclass->get_logger(); and therefore prohibits the latter. I've added documentation for this: Also, note that if you're using a subclass of Log4perl, like package MyL4pWrapper; use Log::Log4perl; our @ISA = qw(Log::Log4perl); and you want to call get_logger() in your code, like use MyL4pWrapper; sub some_function { my $logger = MyL4pWrapper->get_logger(__PACKAGE__); $logger->debug("Hey, there."); } you have to explicitly spell out the category, as in __PACKAGE__ above. You can't rely on # Don't do that! MyL4pWrapper->get_logger(); and assume that Log4perl will take the class of the current package as the category. (Reason behind this is that Log4perl will think you're calling C<get_logger("MyL4pWrapper")> and take "MyL4pWrapper" as the category.)
Fixed in CVS, to be released with 1.15, thanks! -- Mike


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.