QD
QD copied to clipboard
Logging: support lazy construction of message
A frequent pattern of using com.devexperts.logging.Logging#debug(java.lang.String)
is (example from dxfeed-api/src/main/java/com/dxfeed/ipf/live/InstrumentProfileCollector.java
):
if (log.debugEnabled())
log.debug("Removing " + debugString(entry.ip));
— this is supposedly done to avoid resource-intensive computation of message, which is justified, but can be considered boilerplate.
Raw log4j2 addresses this by providing lambda-accepting methods such as org.apache.logging.log4j.Logger#debug(org.apache.logging.log4j.util.Supplier<?>)
. It would be nice if com.devexperts.logging.Logging
supported this as well.