Think about Loose Coupling | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Here is a performance tip for you: If you have some debug statement that was useful/needed in some low level routine that potentially might get called a million times in the real app, use the "constant" pragma to set the value of your debug flag. (see example below). The advantage is that Perl 5.10 and maybe 5.8?, will detect that the "if" statement below could never be true if DEBUG => 0, and that statement is just not even compiled! So there is no run time check of that flag like there would be if say "if $DEBUG were used.
Update: I don't know of any "one size fits all" advice for logging. When I write the code initially, I often have lots of print statements so that I can verify that my logical thinking is right and that the code is doing what I think it is doing. I write some code, debug, then take out most of these print statements. Perl compiles and runs so quickly that using "print" is often easier than fiddling with the debugger! When I release an application to the users, the objective of the logged info is not for me to "debug" the problem meaning know exactly why it happened at a fine level of detail. The objective is for me to have enough information so that I can re-create your problem. Once I can re-create the problem on my machine, then I will figure out "why", maybe by turning on some flags like above in my example.
In reply to Re: Balancing Logging and Code Readability
by Marshall
|
|