Re: [Freeciv-Dev] freelog and LOG_DEBUG
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Markus Linnala wrote:
> I noticed most freelog(LOG_DEBUG, ... instances are like:
> if (0) freelog(LOG_DEBUG, ...);
>
> You don't get any debug information when you define -d 2.
Yeah, that is mainly my doing. The reason is that most of the
time you _don't_ want to see _all_ those messages. There are
still _some_ messages you see with --debug 2; the ones now with
if(0) mostly used to be commented out with /* */, but I found
that format harder to read, and if(0) makes it easier to
selectively turn on or off individual debug statements.
The idea is that for debugging new code, one uses LOG_DEBUG
and --debug 2. Once the code is considered debugged, you
put in if(0) so that you can debug other parts without getting
overwhelmed with cumulative debugging output.
Ok, this probably isn't ideal, and maybe an extra debugging
level would be good (LOG_VERBOSE?). Or something involving
the DEBUG symbol (like your patch). Or a more sophisticated
system where one can turn on or off debugs based on __FILE__.
Some sort of macro system to avoid excessive unnecessary function
calls may be appropriate for efficiency (like your patch).
> There is also situations like:
>
> if(0 && some_func(args)) freelog(LOG_DEBUG, ...);
>
> This is generally bad because you have to be sure there is no
> side effects at some_func. Or else if you enable that particular
> debugging message your code acts differently.
True enough. As I said, these were previously commented out,
so my changes in using if(0) I hope won't have changed anything
since the commenting done by a previous developer.
Regards,
-- David
|
|