Skip to content

Commit

Permalink
Optimize level mapping by using comparison on intValue()
Browse files Browse the repository at this point in the history
  • Loading branch information
loicmathieu committed Sep 11, 2024
1 parent 67b7107 commit a707b21
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,19 @@ public void publish(LogRecord record) {
}

private Severity mapSeverity(Level level) {
if (Level.SEVERE.equals(level)) {
if (level.intValue() == Level.SEVERE.intValue()) {
return Severity.ERROR;
}
if (Level.WARNING.equals(level)) {
if (level.intValue() == Level.WARNING.intValue()) {
return Severity.WARN;
}
if (Level.INFO.equals(level) || Level.CONFIG.equals(level)) {
if (level.intValue() <= Level.INFO.intValue() && level.intValue() >= Level.CONFIG.intValue()) {
return Severity.INFO;
}
if (Level.FINE.equals(level)) {
if (level.intValue() == Level.FINE.intValue()) {
return Severity.DEBUG;
}
if (Level.FINER.equals(level) || Level.FINEST.equals(level) || Level.ALL.equals(level)) {
if (level.intValue() <= Level.FINER.intValue()) {
return Severity.TRACE;
}
return Severity.UNDEFINED_SEVERITY_NUMBER;
Expand Down

0 comments on commit a707b21

Please sign in to comment.