From: Mike S. <m...@pe...> - 2007-09-09 06:11:28
|
On Sat, 8 Sep 2007, Jonathan Swartz wrote: > 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. Ah, gotcha. So you would call $log->debug(...) instead of DEBUG "..." which is probably acceptable in terms of additional key strokes (although it might throw off novices). > The problem I have with the DEBUG etc keywords is that they promote >inefficient behavior. e.g. > > DEBUG "Current arguments: " . Dumper(\@_); > > will take the performance hit for Dumper() even when debug logging > isn't turned on. Sure, although I don't see how $log->debug("Current arguments: " . Dumper(\@_)); is any different. By the way, in Log4perl you can pass a subroutine ref to the method, which eliminates the problem: DEBUG sub { "Current arguments: " . Dumper(\@_) }; Efficient, but ugly :). While you're at it, here's my pipe dream: I want something like Dtrace, where the logging framework zeroes out the opcodes that are currently inactive, and the interpreter rushes through them at light speed with practically no overhead. -- Mike Mike Schilli m...@pe... |