Add a log filter for spurious warnings about unsupported channel options
This commit is contained in:
parent
ad5ef76e8e
commit
0871d6ebc1
|
@ -0,0 +1,26 @@
|
||||||
|
package org.whispersystems.textsecuregcm.util.logging;
|
||||||
|
|
||||||
|
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||||
|
import ch.qos.logback.core.filter.Filter;
|
||||||
|
import ch.qos.logback.core.spi.FilterReply;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filters spurious warnings about setting a very specific channel option on local channels.
|
||||||
|
* <p/>
|
||||||
|
* gRPC unconditionally tries to set the {@code SO_KEEPALIVE} option on all of its channels, but local channels, which
|
||||||
|
* are used by the Noise-over-WebSocket tunnel, do not support {@code SO_KEEPALIVE} and log a warning on each new
|
||||||
|
* channel. We don't want to filter <em>all</em> warnings from the relevant logger, and so this custom filter denies
|
||||||
|
* attempts to log the specific spurious message.
|
||||||
|
*/
|
||||||
|
public class UnknownKeepaliveOptionFilter extends Filter<ILoggingEvent> {
|
||||||
|
|
||||||
|
private static final String MESSAGE_PREFIX = "Unknown channel option 'SO_KEEPALIVE'";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FilterReply decide(final ILoggingEvent event) {
|
||||||
|
final boolean loggerNameMatches = "io.netty.bootstrap.Bootstrap".equals(event.getLoggerName()) ||
|
||||||
|
"io.netty.bootstrap.ServerBootstrap".equals(event.getLoggerName());
|
||||||
|
|
||||||
|
return loggerNameMatches && event.getMessage().startsWith(MESSAGE_PREFIX) ? FilterReply.DENY : FilterReply.NEUTRAL;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package org.whispersystems.textsecuregcm.util.logging;
|
||||||
|
|
||||||
|
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||||
|
import ch.qos.logback.core.filter.Filter;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
|
import io.dropwizard.logging.common.filter.FilterFactory;
|
||||||
|
|
||||||
|
@JsonTypeName("unknownKeepaliveOption")
|
||||||
|
public class UnknownKeepaliveOptionFilterFactory implements FilterFactory<ILoggingEvent> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Filter<ILoggingEvent> build() {
|
||||||
|
return new UnknownKeepaliveOptionFilter();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1 +1,2 @@
|
||||||
org.whispersystems.textsecuregcm.util.logging.RequestLogEnabledFilterFactory
|
org.whispersystems.textsecuregcm.util.logging.RequestLogEnabledFilterFactory
|
||||||
|
org.whispersystems.textsecuregcm.util.logging.UnknownKeepaliveOptionFilterFactory
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<import class="org.whispersystems.textsecuregcm.util.logging.UnknownKeepaliveOptionFilter"/>
|
||||||
|
|
||||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<filter class="UnknownKeepaliveOptionFilter"/>
|
||||||
|
|
||||||
<encoder>
|
<encoder>
|
||||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||||
</encoder>
|
</encoder>
|
||||||
|
|
Loading…
Reference in New Issue