Add Supplier args methods for Logger on java 8.

Hello. The java.util.function.Supplier is supported from Java 8. Some new methods like: public void debug(String format, Supplier<Object> argument); public void debug(String format, Supplier<Object>... arguments); may add to org.slf4j.Logger. Lazy computing improves performance. Old: log.info("INFO a {} b {}",JsonUtil.ObjectToJson(instance),"success"); New: log.info("INFO a {} b {}",()->JsonUtil.ObjectToJson(instance),"success"); The new one with better performance because the ObjectToJson called only on the info level or high. I found slf4j support jdk version older the 8. Maybe we can create a new module for JDK 8. Supplier on slf4j is really an exciting feature. Thanks!

Support for lazy arguments evaluation should be part of slf4j 2.0 https://github.com/qos-ch/slf4j/pull/203 If you want to have it with current slf4j 1.x you can give slf4j-fluent a try https://github.com/ffissore/slf4j-fluent cheers federico JICHUN LIU ha scritto il 19/04/19 alle 15:55:
Hello.
The java.util.function.Supplier is supported from Java 8.
Some new methods like:
public void debug(String format, Supplier<Object> argument);
public void debug(String format, Supplier<Object>... arguments);
may add to org.slf4j.Logger.
Lazy computing improves performance.
Old:
log.info("INFO a {} b {}",JsonUtil.ObjectToJson(instance),"success");
New:
log.info("INFO a {} b {}",()->JsonUtil.ObjectToJson(instance),"success");
The new one with better performance because the ObjectToJson called only on the info level or high.
I found slf4j support jdk version older the 8. Maybe we can create a new module for JDK 8. Supplier on slf4j is really an exciting feature.
Thanks!
_______________________________________________ slf4j-dev mailing list slf4j-dev@qos.ch http://mailman.qos.ch/mailman/listinfo/slf4j-dev

Thanks. It's a good news for me. When will version 2.0 be released? Are there any specific plans? I think a lot of users are waiting for the official release. ________________________________ 发件人: slf4j-dev <slf4j-dev-bounces@qos.ch> 代表 Federico Fissore <federico@fissore.org> 发送时间: 2019年4月19日 14:35 收件人: slf4j developers list 主题: Re: [slf4j-dev] Add Supplier args methods for Logger on java 8. Support for lazy arguments evaluation should be part of slf4j 2.0 https://github.com/qos-ch/slf4j/pull/203 If you want to have it with current slf4j 1.x you can give slf4j-fluent a try https://github.com/ffissore/slf4j-fluent cheers federico JICHUN LIU ha scritto il 19/04/19 alle 15:55:
Hello.
The java.util.function.Supplier is supported from Java 8.
Some new methods like:
public void debug(String format, Supplier<Object> argument);
public void debug(String format, Supplier<Object>... arguments);
may add to org.slf4j.Logger.
Lazy computing improves performance.
Old:
log.info("INFO a {} b {}",JsonUtil.ObjectToJson(instance),"success");
New:
log.info("INFO a {} b {}",()->JsonUtil.ObjectToJson(instance),"success");
The new one with better performance because the ObjectToJson called only on the info level or high.
I found slf4j support jdk version older the 8. Maybe we can create a new module for JDK 8. Supplier on slf4j is really an exciting feature.
Thanks!
_______________________________________________ slf4j-dev mailing list slf4j-dev@qos.ch http://mailman.qos.ch/mailman/listinfo/slf4j-dev
_______________________________________________ slf4j-dev mailing list slf4j-dev@qos.ch http://mailman.qos.ch/mailman/listinfo/slf4j-dev
participants (2)
-
Federico Fissore
-
JICHUN LIU