SLF4J / SLF4J-526 [Open]
Idea for fluent API improvement

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

Here's what changed in this issue in the last few minutes.
This issue has been created
This issue is now assigned to you.

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

==============================
 Issue created
------------------------------

Adrian Shum created this issue on 15/Dec/21 1:09 AM
Summary:              Idea for fluent API improvement
Issue Type:           Improvement
Assignee:             SLF4J developers list
Created:              15/Dec/21 1:09 AM
Priority:             Major
Reporter:             Adrian Shum
Description:
  I found current Fluent API design a bit hard to read for two reasons:
   * method names are too verbose
   * Slightly counter-intuitive to have arguments before the log message
  
   
  
  Especially the second issue, people (at least for me) found it hard to read 
as I need to twist my mind to find corresponding arguments before and after the 
message.
  
  imho it looks a bit better to provide alternatives like this (totally fine to 
keep the original form)
  {code:java}
  logger.atDebug()
          .message("Temperature of {} rise from {} to {}", country)
          .arg(oldTemp).arg(newTemp).log();
  
  // equivalent to 
  
  logger.atDebug()
          .addArgument(country).addArgument(oldTemp).addArgument(newTemp)
          .log("Temperature of {} rise from {} to {}");
  
  // Compare to the old-style
  logger.debug("Temperature of {} rise from {} to {}", country, oldTemp, 
newTemp);
  {code}
   


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

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

Reply via email to