Skip to content

Commit

Permalink
add renderLevel method in SimpleLogger
Browse files Browse the repository at this point in the history
Signed-off-by: Ceki Gulcu <[email protected]>
  • Loading branch information
ceki committed Jan 8, 2024
1 parent 7aa44f3 commit 85d905c
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion slf4j-simple/src/main/java/org/slf4j/simple/SimpleLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ private void innerHandleNormalizedLoggingCall(Level level, List<Marker> 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(']');
Expand Down Expand Up @@ -439,6 +439,22 @@ private void innerHandleNormalizedLoggingCall(Level level, List<Marker> 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();

Expand Down

0 comments on commit 85d905c

Please sign in to comment.