IDEA
Original idea is here - https://github.com/MicroUtils/kotlin-logging

The idea is to pass Supplier<String> to debug (info, error, etc.)
methods instead of template string and object varargs array.

KOTLIN (just for example)
In kotlin it looks like that:

logger.debug { "Some $expensive message!" }

So you pass just function and framework decides evaluate for message
producing it or not.

JAVA
in java it may looks like that:

logger.debug(() -> "Code which produce heavy log message"));

or

logger.debug(() -> {
    return "Code which produce heavy log message"
}));

E.g. we put isDebugEnabled call into framework and make code cleaner.

IMPLEMENTATION
It is necessary to add counterpart method with Supplier<String>
argument for all methods that have final String s, final Object...
objects arguments in signature.

DISADVANATAGES
For now I can see only one - slf4j framework will require java 8 version


Do you agree to add such feature?
Feel free to ask any me any questions.
_______________________________________________
slf4j-dev mailing list
slf4j-dev@qos.ch
http://mailman.qos.ch/mailman/listinfo/slf4j-dev

Reply via email to