replaced EvaluatorFilter with custom regex-based filter and removed non-dependency

This commit is contained in:
Jason_DiDonato@yahoo.com 2021-07-02 07:30:29 -04:00
parent abf7135e64
commit a6b09faa84
3 changed files with 36 additions and 24 deletions

View file

@ -0,0 +1,29 @@
package net.psforever.filters;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.filter.Filter;
import ch.qos.logback.core.spi.FilterReply;
/**
* Disrupts a variety of messages that, when formatted, match against the configured regular expression.
* A replacement for the `EvaluatorFilter`.
*/
public class MsgRegexFilter extends Filter<ILoggingEvent> {
private String regex;
@Override
public FilterReply decide(ILoggingEvent event) {
if (isStarted() && event.getFormattedMessage().matches(regex)) {
return FilterReply.DENY;
} else {
return FilterReply.NEUTRAL;
}
}
@Override
public void start() {
if (this.regex != null) {
super.start();
}
}
}