private Level(final String name, final int intLevel) { if (Strings.isEmpty(name)) { throw new IllegalArgumentException("Illegal null or empty Level name."); } if (intLevel < 0) { throw new IllegalArgumentException("Illegal Level int less than zero."); } this.name = name; this.intLevel = intLevel; this.standardLevel = StandardLevel.getStandardLevel(intLevel); if (LEVELS.putIfAbsent(name, this) != null) { throw new IllegalStateException("Level " + name + " has already been defined."); } }
private Level(final String name, final int intLevel) { if (Strings.isEmpty(name)) { throw new IllegalArgumentException("Illegal null or empty Level name."); } if (intLevel < 0) { throw new IllegalArgumentException("Illegal Level int less than zero."); } this.name = name; this.intLevel = intLevel; this.standardLevel = StandardLevel.getStandardLevel(intLevel); if (LEVELS.putIfAbsent(name, this) != null) { throw new IllegalStateException("Level " + name + " has already been defined."); } }
@Override public SeverityLevel getNormalizedSeverityLevel() { int log4jLevelAsInt = logEvent.getLevel().intLevel(); switch (StandardLevel.getStandardLevel(log4jLevelAsInt)) { case FATAL: return SeverityLevel.Critical; case ERROR: return SeverityLevel.Error; case WARN: return SeverityLevel.Warning; case INFO: return SeverityLevel.Information; case TRACE: case DEBUG: case ALL: return SeverityLevel.Verbose; default: InternalLogger.INSTANCE.error("Unknown Log4j v2 option, %d, using TRACE level as default", log4jLevelAsInt); return SeverityLevel.Verbose; } } }