From 7029a8b7fda826f425c740a847e97f4c0a063dbe Mon Sep 17 00:00:00 2001 From: Ceki Gulcu Date: Mon, 8 Jan 2024 15:02:22 +0100 Subject: [PATCH] add renderLevel method in SimpleLogger Signed-off-by: Ceki Gulcu --- .../java/org/slf4j/simple/SimpleLogger.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/slf4j-simple/src/main/java/org/slf4j/simple/SimpleLogger.java b/slf4j-simple/src/main/java/org/slf4j/simple/SimpleLogger.java index 93638ee82..9b8b99ff0 100644 --- a/slf4j-simple/src/main/java/org/slf4j/simple/SimpleLogger.java +++ b/slf4j-simple/src/main/java/org/slf4j/simple/SimpleLogger.java @@ -409,7 +409,7 @@ private void innerHandleNormalizedLoggingCall(Level level, List markers, buf.append('['); // Append a readable representation of the log level - String levelStr = level.name(); + String levelStr = renderLevel(level.toInt()); buf.append(levelStr); if (CONFIG_PARAMS.levelInBrackets) buf.append(']'); @@ -439,6 +439,22 @@ private void innerHandleNormalizedLoggingCall(Level level, List markers, write(buf, t); } + protected String renderLevel(int level) { + switch (level) { + case LOG_LEVEL_TRACE: + return "TRACE"; + case LOG_LEVEL_DEBUG: + return("DEBUG"); + case LOG_LEVEL_INFO: + return "INFO"; + case LOG_LEVEL_WARN: + return "WARN"; + case LOG_LEVEL_ERROR: + return "ERROR"; + } + throw new IllegalStateException("Unrecognized level ["+level+"]"); + } + public void log(LoggingEvent event) { int levelInt = event.getLevel().toInt();