Skip Menu |

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

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

People
Owner: lammel [...] cpan.org
Requestors: MSCHILLI [...] cpan.org
Cc:
AdminCc:

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



Subject: Suggestions for method names
Wow, this is great! I just sat down in order to write exactly this module, and luckily I checked CPAN beforehand -- thanks so much for writing this! I'll add it to my Log4perl talk at OSCON on 7/24. I noticed that you've chosen log() as the method name, which makes perfect sense to me but I was wondering if we should provide more options. For example, the LogDispatch guys are using logger(), so if we want interoperability, it'd be nice if we could add that too as an alias. Would be cool to use log4perl- or logdispatch- enabled code without modifications. Another option which would probably appeal to lazy people (like myself): $self->log_debug() and make the prefix "log_" configurable so that you could say with MooseX::Log::Log4perl (prefix => ""); sub foo { my $self = shift; $self->debug("hi!"); } at which point we could put it under the :easy umbrella: with MooseX::Log::Log4perl (:easy); What do you think? Anyways, just wanted to say thanks for the module, keep up the great work! -- Mike
On Sun Jul 13 15:47:10 2008, MSCHILLI wrote: Show quoted text
> Wow, this is great! I just sat down in order to write exactly this > module, and luckily I checked CPAN beforehand -- thanks so much for > writing this! I'll add it to my Log4perl talk at OSCON on 7/24.
Hey, I'm happy to finally give something back to the perl community! Show quoted text
> I noticed that you've chosen log() as the method name, which makes > perfect sense to me but I was wondering if we should provide more
options. Show quoted text
> > For example, the LogDispatch guys are using logger(), so if we want > interoperability, it'd be nice if we could add that too as an alias. > Would be cool to use log4perl- or logdispatch- enabled code without > modifications.
I actually defined to logger attribute with the attribute name "logger", so it should be possible to simply call that too, e.g.: <snip> with MooseX::Log::Log4perl; sub bar { my ($self, $baz) = @_; $self->logger->debug($baz); $self->log('OtherCategory')->info("We did it"); } </snip> Show quoted text
> Another option which would probably appeal to lazy people (like myself): > > $self->log_debug() > > and make the prefix "log_" configurable so that you could say > > with MooseX::Log::Log4perl (prefix => ""); > > sub foo { > my $self = shift; > $self->debug("hi!"); > } > > at which point we could put it under the :easy umbrella: > > with MooseX::Log::Log4perl (:easy); > > What do you think?
I really like that suggestion, I'd just have to get my had into Moose a little deeper to do it in the right way (guess I simply have to setup the methods myself on import). I guess a sane default would be to use "log_" as a prefix as you suggested, to not cause to many name clashes with methods like "error". Show quoted text
> Anyways, just wanted to say thanks for the module, keep up the great work! > > -- Mike >
Thanks for the suggestion and interest, and thanks for Log4perl!
The suggested "easy" interface has been added to MooseX::Log::Log4perl as a new role MooseX::Log::Log4perl::Easy (the docs might still be improved later). This adds the methods ->log_fatal ->log_error ->log_warn ->log_info ->log_debug ->log_trace It reuses the MooseX::Log::Log4perl role, so it also allows to access the logger and log method. The more flexible interface wil be added later.
No further requests showed up, so the Easy interface is considered fine enough for now. Finally resolving...