You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2016/08/19 10:02:47 UTC
cxf git commit: [CXF-7000] Updating only core
AbstractLoggingInterceptor to check if the logging is required at a given
point of time, with thanks to Ingo Weiss
Repository: cxf
Updated Branches:
refs/heads/master 5a6b69b38 -> d534ecc1d
[CXF-7000] Updating only core AbstractLoggingInterceptor to check if the logging is required at a given point of time, with thanks to Ingo Weiss
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/d534ecc1
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/d534ecc1
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/d534ecc1
Branch: refs/heads/master
Commit: d534ecc1d25ab4d38aaa690cb75debe9816958ee
Parents: 5a6b69b
Author: Sergey Beryozkin <sb...@gmail.com>
Authored: Fri Aug 19 11:02:32 2016 +0100
Committer: Sergey Beryozkin <sb...@gmail.com>
Committed: Fri Aug 19 11:02:32 2016 +0100
----------------------------------------------------------------------
.../cxf/interceptor/AbstractLoggingInterceptor.java | 10 ++++++++++
.../apache/cxf/interceptor/LoggingOutInterceptorTest.java | 7 +++++++
2 files changed, 17 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/d534ecc1/core/src/main/java/org/apache/cxf/interceptor/AbstractLoggingInterceptor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/interceptor/AbstractLoggingInterceptor.java b/core/src/main/java/org/apache/cxf/interceptor/AbstractLoggingInterceptor.java
index 0a0beb1..73912b7 100644
--- a/core/src/main/java/org/apache/cxf/interceptor/AbstractLoggingInterceptor.java
+++ b/core/src/main/java/org/apache/cxf/interceptor/AbstractLoggingInterceptor.java
@@ -36,6 +36,7 @@ import javax.xml.stream.XMLStreamWriter;
import javax.xml.transform.stream.StreamSource;
import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.PropertyUtils;
import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.endpoint.Endpoint;
import org.apache.cxf.io.CachedOutputStream;
@@ -55,6 +56,7 @@ public abstract class AbstractLoggingInterceptor extends AbstractPhaseIntercepto
protected static final String BINARY_CONTENT_MESSAGE = "--- Binary Content ---";
protected static final String MULTIPART_CONTENT_MESSAGE = "--- Multipart Content ---";
private static final String MULTIPART_CONTENT_MEDIA_TYPE = "multipart";
+ private static final String LIVE_LOGGING_PROP = "org.apache.cxf.logging.enable";
private static final List<String> BINARY_CONTENT_MEDIA_TYPES;
static {
BINARY_CONTENT_MEDIA_TYPES = new ArrayList<String>();
@@ -78,9 +80,17 @@ public abstract class AbstractLoggingInterceptor extends AbstractPhaseIntercepto
super(id, phase);
}
+ protected static boolean isLoggingDisabledNow(Message message) throws Fault {
+ Object liveLoggingProp = message.getContextualProperty(LIVE_LOGGING_PROP);
+ return liveLoggingProp != null && PropertyUtils.isFalse(liveLoggingProp);
+ }
+
protected abstract Logger getLogger();
Logger getMessageLogger(Message message) {
+ if (isLoggingDisabledNow(message)) {
+ return null;
+ }
Endpoint ep = message.getExchange().getEndpoint();
if (ep == null || ep.getEndpointInfo() == null) {
return getLogger();
http://git-wip-us.apache.org/repos/asf/cxf/blob/d534ecc1/core/src/test/java/org/apache/cxf/interceptor/LoggingOutInterceptorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/interceptor/LoggingOutInterceptorTest.java b/core/src/test/java/org/apache/cxf/interceptor/LoggingOutInterceptorTest.java
index 832f738..88019e0 100644
--- a/core/src/test/java/org/apache/cxf/interceptor/LoggingOutInterceptorTest.java
+++ b/core/src/test/java/org/apache/cxf/interceptor/LoggingOutInterceptorTest.java
@@ -24,6 +24,7 @@ import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
+import java.util.HashMap;
import java.util.logging.Logger;
import org.apache.cxf.common.logging.LogUtils;
@@ -32,9 +33,11 @@ import org.apache.cxf.io.CachedOutputStream;
import org.apache.cxf.message.ExchangeImpl;
import org.apache.cxf.message.Message;
import org.apache.cxf.message.MessageImpl;
+import org.apache.cxf.service.model.BindingInfo;
import org.apache.cxf.service.model.EndpointInfo;
import org.easymock.EasyMock;
import org.easymock.IMocksControl;
+
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@@ -153,6 +156,10 @@ public class LoggingOutInterceptorTest extends Assert {
Endpoint endpoint = control.createMock(Endpoint.class);
EndpointInfo endpointInfo = control.createMock(EndpointInfo.class);
EasyMock.expect(endpoint.getEndpointInfo()).andReturn(endpointInfo).anyTimes();
+ BindingInfo bindingInfo = control.createMock(BindingInfo.class);
+ EasyMock.expect(endpointInfo.getBinding()).andReturn(bindingInfo).anyTimes();
+ EasyMock.expect(endpointInfo.getProperties()).andReturn(new HashMap<String, Object>()).anyTimes();
+ EasyMock.expect(bindingInfo.getProperties()).andReturn(new HashMap<String, Object>()).anyTimes();
control.replay();
Message message = new MessageImpl();