mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-20 09:28:03 +01:00
Add filters/tasks to enable/disable request logging.
This commit is contained in:
committed by
Jon Chambers
parent
ab62c19de9
commit
1732cf9243
@@ -0,0 +1,18 @@
|
||||
package org.whispersystems.textsecuregcm.util.logging;
|
||||
|
||||
import ch.qos.logback.core.filter.Filter;
|
||||
import ch.qos.logback.core.spi.FilterReply;
|
||||
|
||||
class RequestLogEnabledFilter<E> extends Filter<E> {
|
||||
|
||||
private volatile boolean requestLoggingEnabled = false;
|
||||
|
||||
@Override
|
||||
public FilterReply decide(final E event) {
|
||||
return requestLoggingEnabled ? FilterReply.NEUTRAL : FilterReply.DENY;
|
||||
}
|
||||
|
||||
public void setRequestLoggingEnabled(final boolean requestLoggingEnabled) {
|
||||
this.requestLoggingEnabled = requestLoggingEnabled;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.whispersystems.textsecuregcm.util.logging;
|
||||
|
||||
import ch.qos.logback.access.spi.IAccessEvent;
|
||||
import ch.qos.logback.core.filter.Filter;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import io.dropwizard.logging.filter.FilterFactory;
|
||||
|
||||
@JsonTypeName("requestLogEnabled")
|
||||
class RequestLogEnabledFilterFactory implements FilterFactory<IAccessEvent> {
|
||||
|
||||
@Override
|
||||
public Filter<IAccessEvent> build() {
|
||||
return RequestLogManager.getHttpRequestLogFilter();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.whispersystems.textsecuregcm.util.logging;
|
||||
|
||||
import ch.qos.logback.access.spi.IAccessEvent;
|
||||
import ch.qos.logback.core.filter.Filter;
|
||||
import org.whispersystems.websocket.logging.WebsocketEvent;
|
||||
|
||||
public class RequestLogManager {
|
||||
private static final RequestLogEnabledFilter<IAccessEvent> HTTP_REQUEST_LOG_FILTER = new RequestLogEnabledFilter<>();
|
||||
|
||||
static Filter<IAccessEvent> getHttpRequestLogFilter() {
|
||||
return HTTP_REQUEST_LOG_FILTER;
|
||||
}
|
||||
|
||||
public static void setRequestLoggingEnabled(final boolean enabled) {
|
||||
HTTP_REQUEST_LOG_FILTER.setRequestLoggingEnabled(enabled);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user