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
------------------------------

Piotr P. Karwasz on 02/Jan/23 11:45 PM
[~cowwoc],

You can not use method references with a parameter of type {{Object}}. Method 
references work only if the compiler detects a functional interface type.

Therefore you can either introduce a {{Logger#debug(String, Supplier<?>...)}} 
method (like in Log4j2 API) and write:

{code:java}
log.debug("{}, {} and {} share a value of {}", () -> first, () -> second, () -> 
third, this::getExpensiveComputation);
{code}

(I am not a big fan of this solution) or improve the old {{Logger#debug(String, 
Object...)}} method and write:

{code:java}
log.debug("{}, {} and {} share a value of {}", first, second, third, 
(Supplier<?>) this::getExpensiveComputation);
{code}

The second solution would probably require a minor version bump (IMHO), the 
second one can probably be implemented with a default interface method.


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

_______________________________________________
slf4j-dev mailing list
[email protected]
https://mailman.qos.ch/cgi-bin/mailman/listinfo/slf4j-dev

Reply via email to