Log of debugging messages is enabled in non-debugging builds
The message facility is supposed, by
art prescription, to disable the dispatch of debug messages in production builds (
Currently this dispatch is enabled in all cases.
This can cause slow-down (in some cases, a severe one).
art prescriptions will lead to a general speed up of the code (mileage varies greatly!) and less ability of debug logging in production builds.
#2 Updated by Gianluca Petrillo almost 7 years ago
- % Done changed from 0 to 80
LOG_DEBUG macro, defined in
messagefacility package, is disabled when in production mode (in our case,
It relies on the standard macro
NDEBUG: if the latter is defined,
LOG_DEBUG is (close to?) a no-op.
The standard macro
NDEBUG is also the one determining whether the
assert macro is enabled or not.
For that reason and some questionable code practices (#5174),
NDEBUG was forcibly deactivated in most of LArSoft, causing
LOG_DEBUG to come back alive.
The fact that
LOG_DEBUG is honoured is usually not seen, because normally the debug log stream is dropped anyway.
But it is felt, because before dropping it, the message is fully computed.
The most spectacular example is in
LArG4 module, where
LOG_DEBUG appears in a inner loop called tens of millions of times per event.
#3 Updated by Gianluca Petrillo almost 7 years ago
Committed a fix aimed to deactivate
LOG_DEBUG macro for non-production builds (the same ones where
NDEBUG would be normally set).
This is a temporary fix: once issue #5174 is fixed, both this change and the removal of
NDEBUG will go.
LOG_DEBUG does not emit messages anymore unless using the
debug qualifier, regardless the verbosity level configured in FCL files.
This was the intended behaviour per
art directions, and it can yield relevant improvements to execution speed.
If you really, really want debug information in a non-debug build, you can still use
mf::LogDebug, adding the file and line number information by hand:
::mf::LogDebug("MyDebug", __FILE__, __LINE__) << "this message is too important to be skipped";
(I haven't checked this line, it's just to give the idea).