>
 > On Sep 8, 2007, at 1:19 PM, Mike Schilli wrote:
 >
 > > On Fri, 7 Sep 2007, Jonathan Swartz wrote:
 > >
 > > I'd be interested in feedback on a proposed module, Log::Abstract,
 > > described here:
 > >
 > >      http://use.perl.org/~jonswar/journal/34366
 >
 > ...
 >
 > By the way, I don't agree that "For small modules that want to
 > minimize dependencies, depending on Log4perl (for example) is a
 > non-starter." The Log4perl core doesn't have dependencies other
 > than perl's core modules.

Fair enough.

 >
 > One thing missing from your proposal is Log4perl's :easy mode
 > [sourceforge.net]. If you think about it, getting a logger and
 > calling its method is a lot of typing, given that you just want
 > to log something. That's why in Log4perl you can use
 >
 > DEBUG "Log this!";
 >
 > and you're done. No getting a logger, no method calling, no
 > category passing. It's all automatic. Behind the scenes, it gets
 > a 'stealth logger' with the category set to the current package
 > and calls the appropriate logging method on it. This feature is
 > huge. I'm using it almost exclusively in everything I write.
 >
 > Any chance of adding that?

Did you see this in the posting?

     As a convenient shorthand, you can use

             package Foo;
             use Log::Abstract qw($log);

     to create the logger, which is equivalent to the first example  
except that $log is
     (necessarily) a package-scoped rather than lexical variable.

So this creates a logger for you with the category set to the current  
package, similar to easy mode. The syntax is pretty minimal. The  
problem I have with the DEBUG etc keywords is that they promote  
inefficient behavior. e.g.

     DEBUG "Current arguments: " . Dumper([EMAIL PROTECTED]);

will take the performance hit for Dumper() even when debug logging  
isn't turned on. This may be fine for a particular application where  
performance is not an issue, but I would never want to encourage any  
CPAN module author to do this.

In fact, in this thread on perl.module-authors,

     http://groups.google.com/group/perl.module-authors/msg/ 
cbd5a168d5d780a8?hl=en&

it was suggested that even the usual "fast" $log->is_debug() check is  
too much of a hit. So I proposed we export a live $log_is_debug  
variable that would change dynamically to reflect the current level.

I suppose one could combine the syntaxes:

     DEBUG "Current arguments: " . Dumper([EMAIL PROTECTED]) if $log_is_debug;

but at this point you are only saving 6 characters or so.

 >
 > One thing to watch out for is performance. People don't want
 > their applications to slow down just because a module has a
 > logging capability.

Exactly my point above. :)

Thanks for your positive feedback! I will definitely need to have the  
support of major logging frameworks such as log4perl for this module  
to be a success.

Best,
Jon


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel

Reply via email to