Skip to content

Commit

Permalink
use MessageFormat insetad of String.format to comply spec of System.L…
Browse files Browse the repository at this point in the history
…ogger.log

Signed-off-by: Taku Miyakawa <miyakawa.taku@gmail.com>
  • Loading branch information
miyakawataku authored and ceki committed Aug 8, 2023
1 parent e63f87f commit 0769bc8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import static java.util.Objects.requireNonNull;

import java.text.MessageFormat;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

Expand Down Expand Up @@ -142,7 +143,7 @@ private void performLog(org.slf4j.event.Level slf4jLevel, ResourceBundle bundle,
leb = leb.addArgument(p);
}
// The JDK uses a different formatting convention. We must invoke it now.
message = String.format(message, params);
message = MessageFormat.format(message, params);
}
if (leb instanceof CallerBoundaryAware) {
CallerBoundaryAware cba = (CallerBoundaryAware) leb;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void smoke() throws IOException {
assertEquals(EXPECTED_FINDER_CLASS, finder.getClass().getName());
Logger systemLogger = finder.getLogger("smoke", null);
systemLogger.log(Level.INFO, "hello");
systemLogger.log(Level.INFO, "hello %s", "world");
systemLogger.log(Level.INFO, "hello {0}", "world");

List<String> results = SPS.stringList;
assertEquals(2, results.size());
Expand Down

0 comments on commit 0769bc8

Please sign in to comment.