Beefy Boxes and Bandwidth Generously Provided by pair Networks
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.
#!/usr/bin/perl -w use strict; use constant DEBUG => 1; print "this is debug" if DEBUG;
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
in thread Balancing Logging and Code Readability by ack

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-03-29 12:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found