QD icon indicating copy to clipboard operation
QD copied to clipboard

Logging: support lazy construction of message

Open dtruebin opened this issue 1 year ago • 0 comments

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.

dtruebin avatar Nov 17 '23 19:11 dtruebin