Project

General

Profile

Support #5147

use of #define to turn on/off messaging should be changed to LOG_DEBUG or another LOG_XXX macro

Added by Brian Rebel almost 7 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Category:
-
Target version:
Start date:
01/05/2014
Due date:
% Done:

90%

Estimated time:
Experiment:
-
Co-Assignees:
Duration:

Description

Some code is using #define to get the compiler to turn on/off debugging messages. The message facility LOG_DEBUG does this already with the added benefit of not having to recompile the code. The LOG_DEBUG messages are automatically turned off when compiled in the optimized build. If the message level should be something other than DEBUG, there are similar macros for LOG_VERBATIM, LOG_INFO, LOG_WARNING and LOG_ERROR.

An example of code using of the #define is RecoAlg/CCHitFinder.h(cxx)

There may be other instances in the LArSoft code. I noticed this one while looking at a commit message from the svn repository.

LogDebugInCode.txt (1.72 KB) LogDebugInCode.txt Gianluca Petrillo, 04/15/2014 08:07 PM

History

#1 Updated by Erica Snider almost 7 years ago

  • Status changed from New to Assigned
  • Assignee set to Erica Snider
  • Target version set to v1_01_00

#2 Updated by Gianluca Petrillo over 6 years ago

  • Assignee changed from Erica Snider to Gianluca Petrillo

#3 Updated by Gianluca Petrillo over 6 years ago

LOG_VERBOSE and friends, as LOG_DEBUG, also add file name and line number to the message, but for the rest they behave just like the corresponding mf::LogWarning etc.
But LOG_DEBUG is the real deal here, since in non-debug mode (NDEBUG macro defined) the message is not only not printed, but not even put together: a no-operation.
The same is not true for the other macros.

#4 Updated by Gianluca Petrillo over 6 years ago

  • File LogDebugInCode.txt added
  • % Done changed from 0 to 80

I have parsed the code.
The places where LogDebug is used are not many.
I have replaced a few with LOG_DEBUG, when performance or clarity of the output could potentially be a concern.
Otherwise, I have left LogDebug, which can output also in profiling builds (that can be helpful for quick diagnosis).

Still some action can be taken in larreco/TrackFinder/Track3DKalmanSPS_module.cc, which has an alternative way to control the debug output from GenFit.

#5 Updated by Gianluca Petrillo over 6 years ago

  • Status changed from Assigned to Resolved
  • % Done changed from 80 to 90

Changes are complete and committed.
There is some transition in Track3DKalmanSPS, where the output from GenFit was controlled by a configuration parameter.
Now the output is via LOG_DEBUG and we should consider removing the parameter and rely completely on the message logger (those messages have now their own category). In the committed version, it is just stated that the parameter GenfPRINT is deprecated.

Incidentally, I have not noticed any #define for the control of the output.

#6 Updated by Gianluca Petrillo over 6 years ago

I have replaced all the remaining instances of mf::LogDebug, with the exception of three places where the output is spread in different parts of code and the replacement is not feasible.
In these cases, if statements protect the log message insertions and comments explain what is happening.
This also reverts the changes which provoked exceptions with SLF6 (!).

#7 Updated by Gianluca Petrillo over 6 years ago

  • File deleted (LogDebugInCode.txt)

#8 Updated by Gianluca Petrillo over 6 years ago

  • Status changed from Resolved to Closed


Also available in: Atom PDF