LogCustomizer should support slf4j log levels
@@ -93,11 +93,21 @@ public class LogCustomizer {
return this;
}
+ public LogCustomizerBuilder enable(org.slf4j.event.Level level) {
+ this.enableLevel = fromSlf4jLevel(level);
+ return this;
+ }
+
public LogCustomizerBuilder filter(Level level) {
this.filterLevel = level;
return this;
}
+ public LogCustomizerBuilder filter(org.slf4j.event.Level level) {
+ this.filterLevel = fromSlf4jLevel(level);
+ return this;
+ }
+
public LogCustomizerBuilder exactlyMatches(String message) {
this.matchExactMessage = message;
return this;
@@ -116,6 +126,23 @@ public class LogCustomizer {
public LogCustomizer create() {
return new LogCustomizer(name, enableLevel, filterLevel, matchExactMessage, matchContainsMessage, matchRegexMessage);
}
+
+ private static Level fromSlf4jLevel(org.slf4j.event.Level level) {
+ switch (level) {
+ case DEBUG:
+ return Level.DEBUG;
+ case ERROR:
+ return Level.ERROR;
+ case INFO:
+ return Level.INFO;
+ case TRACE:
+ return Level.TRACE;
+ case WARN:
+ return Level.WARN;
+ default:
+ throw new IllegalArgumentException("Log level not supported: " + level);
+ }
+ }
}
private final Logger logger;
