[slf4j-dev] [JIRA] Updates for SLF4J-371: Support the lambda expression in the Logger

QOS.CH (JIRA) noreply-jira at qos.ch
Sun Nov 20 22:38:00 CET 2022


SLF4J / SLF4J-371 [Resolved]
Support the lambda expression in the Logger

==============================

Here's what changed in this issue in the last few minutes.

There is 1 comment.

View or comment on issue using this link
https://jira.qos.ch/browse/SLF4J-371

==============================
 1 comment
------------------------------

Ondrej Zizka on 20/Nov/22 10:23 PM
Yes, using Spring Boot. In a project without Spring Boot, it was ok. But I did not go further into it yet as it works with the older.

In Kotlin, one can write these 3 lines to make the evaluation lazy:

{color:#002586}fun {color}{color:#000000}Logger{color}{color:#d50c0c}.{color}{color:#00627a}info{color}{color:#940076}( {color}provider: {color:#940076}() -> {color}{color:#000000}String {color}{color:#940076}) {color}{ {color:#002586}if {color}{color:#940076}({color}{color:#002586}this{color}{color:#d50c0c}.{color}{color:#871094}isInfoEnabled{color}{color:#940076}) {color}{color:#002586}this{color}{color:#d50c0c}.{color}info{color:#940076}({color}provider{color:#d50c0c}.{color}invoke{color:#940076}()) {color}}
{color:#002586}fun {color}{color:#000000}Logger{color}{color:#d50c0c}.{color}{color:#00627a}debug{color}{color:#940076}( {color}provider: {color:#940076}() -> {color}{color:#000000}String {color}{color:#940076}) {color}{ {color:#002586}if {color}{color:#940076}({color}{color:#002586}this{color}{color:#d50c0c}.{color}{color:#871094}isDebugEnabled{color}{color:#940076}) {color}{color:#002586}this{color}{color:#d50c0c}.{color}debug{color:#940076}({color}provider{color:#d50c0c}.{color}invoke{color:#940076}()) {color}}
{color:#002586}fun {color}{color:#000000}Logger{color}{color:#d50c0c}.{color}{color:#00627a}trace{color}{color:#940076}( {color}provider: {color:#940076}() -> {color}{color:#000000}String {color}{color:#940076}) {color}{ {color:#002586}if {color}{color:#940076}({color}{color:#002586}this{color}{color:#d50c0c}.{color}{color:#871094}isTraceEnabled{color}{color:#940076}) {color}{color:#002586}this{color}{color:#d50c0c}.{color}trace{color:#940076}({color}provider{color:#d50c0c}.{color}invoke{color:#940076}()) {color}}

And then just:
{code:java}
log.trace { "State dump: " + expensiveLongSerialisation(state) }{code}
Still, it would be nice to have that in Slf4j directly.


==============================
 This message was sent by Atlassian Jira (v8.8.0#808000-sha1:e2c7e59)



More information about the slf4j-dev mailing list