use of #define to turn on/off messaging should be changed to LOG_DEBUG or another LOG_XXX macro
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.
#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
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 (!).