Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re^2: Balancing Logging and Code Readability

by saberworks (Curate)
on Sep 15, 2009 at 15:36 UTC ( #795411=note: print w/replies, xml ) Need Help??

in reply to Re: Balancing Logging and Code Readability
in thread Balancing Logging and Code Readability

Another common thing to accomplish something similar is to declare a vprint() or vwarn() function and have the check for DEBUG only occur there (instead of all over the place in your code). Then you just vprint("debug stuff") everywhere. Still doesn't get rid of the clutter but it ends up being a bit less than trailing if DEBUG everywhere.
  • Comment on Re^2: Balancing Logging and Code Readability

Replies are listed 'Best First'.
Re^3: Balancing Logging and Code Readability
by ack (Deacon) on Sep 17, 2009 at 02:39 UTC

    Very good suggestion and straegy. That strategy can be extended to several other challenges I've encountered with logging...and with debugging, too. In fact, whether one uses logging or (as I noted to Marshall) just straight prints for debugging, gathering the frequently repeated code(s) into subroutines always makes my code much more readable and much less "cluttered."

    Excellent observation and suggestion. Thanks, saberworks.

    ack Albuquerque, NM

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://795411]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2021-03-04 19:04 GMT
Find Nodes?
    Voting Booth?
    My favorite kind of desktop background is:

    Results (107 votes). Check out past polls.