Hi,

I am wondering to extend the org.apache.commons.logging.Log interface with 
default methods. 

It could simplify the usage, instead of

if (log.isDebugEnabled()) {
        log.debug("something heavy  " + here);
}

could use lambda expression
log.debug(() -> "something heavy  " + here);

to prevent the payload creation if the certain log level not enabled.

so the org.apache.commons.logging.Log interface would get the following default 
methods:

        default void debug(Supplier<Object> msgSupplier) {
                if (isDebugEnabled()) {
                        debug(msgSupplier != null ? msgSupplier.get() : null);
                }
        }

        default void debug(Supplier<Object> msgSupplier, Throwable t) {
                if (isDebugEnabled()) {
                        debug(msgSupplier != null ? msgSupplier.get() : null, 
t);
                }
        }

of course not just for debug, I would create for all the log levels.

Obviously that should need a new version like 1.3.0 because the Java source and 
target level must raise to 1.8 from the current 1.6.

What do you think, is the community would accept this change?

Regards, Balazs

Reply via email to