NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Logging (Score:1)
Did you mean: Log::Log4perl [cpan.org]
Re: (Score:2)
print STDERR "We are now in func2\n";
print STDERR "we got params:\n", Dumper \@params;
We have a lot of such code. I attempt only to inject
when really desperately debugging or atleast isolating it behind
if (DEBUG) {
Re: (Score:1)
That’s the point: with Log4perl, you can leave it in. You configure at runtime precisely which logging messages you’re interested in (yes, while the program runs – not just at startup).
Furthermore, if you worry about expensive computations in your logging statements, you can pass a closure instead of a string, which will be invoked only if that statement is enabled. The logger call still happens, so this is not as efficient as
if (DEBUG) { ... }(which is completely optimised away at comRe: (Score:2)
Thanks,
Re:Logging (Score:1)
Ah, didn’t know you knew it already. A lot of people don’t, and logging is one of those things where it’s really really easy to understand and solve 30% of the problem, but it’s hard to imagine the whole problem and a lot of work to solve it well, so it’s common to get stuck at the 30% threshold.
I was stuck there too before I read an article about Log4perl. It really opened my eyes – I had been doing things in a pretty crappy way but it never occurred to me I could have better. So now whenever I see someone wringing their hands about log/debug statements, I tell them to look at Log4perl.
(After that article, I looked at other logging modules, because I wasn’t sure whether Log4perl is really that great or I just hadn’t seen any better before. Turns out it really is that great; only Log::Dispatch is close.)
Reply to This
Parent