You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2017/03/13 14:22:12 UTC

cxf git commit: Update to support the inlogging stuff as well.

Repository: cxf
Updated Branches:
  refs/heads/master e36d2ad10 -> be6190da7


Update to support the inlogging stuff as well.


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/be6190da
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/be6190da
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/be6190da

Branch: refs/heads/master
Commit: be6190da7b0a05c505c99668270c993cd94a0eb2
Parents: e36d2ad
Author: Daniel Kulp <dk...@apache.org>
Authored: Mon Mar 13 10:21:56 2017 -0400
Committer: Daniel Kulp <dk...@apache.org>
Committed: Mon Mar 13 10:21:56 2017 -0400

----------------------------------------------------------------------
 .../ext/logging/LoggingFactoryBeanListener.java | 45 ++++++++++++++------
 1 file changed, 31 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/be6190da/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/LoggingFactoryBeanListener.java
----------------------------------------------------------------------
diff --git a/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/LoggingFactoryBeanListener.java b/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/LoggingFactoryBeanListener.java
index f4f31d3..6af2b17 100644
--- a/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/LoggingFactoryBeanListener.java
+++ b/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/LoggingFactoryBeanListener.java
@@ -27,9 +27,10 @@ import java.net.URI;
 import org.apache.cxf.Bus;
 
 import org.apache.cxf.annotations.Logging;
-
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.ext.logging.event.LogEventSender;
 import org.apache.cxf.ext.logging.event.PrintWriterEventSender;
 import org.apache.cxf.service.factory.AbstractServiceFactoryBean;
 import org.apache.cxf.service.factory.FactoryBeanListener;
@@ -78,6 +79,28 @@ public class LoggingFactoryBeanListener implements FactoryBeanListener {
         }
     }
 
+    
+    private LogEventSender createEventSender(String location) {
+        if (StringUtils.isEmpty(location)) {
+            return null;
+        }
+        if ("<stdout>".equals(location)) {
+            return new PrintWriterEventSender(System.out);
+        } else if ("<stderr>".equals(location)) {
+            return new PrintWriterEventSender(System.err);                
+        } else if (location.startsWith("file:")) {
+            try {
+                URI uri = new URI(location);
+                File file = new File(uri);
+                PrintWriter writer = new PrintWriter(new FileWriter(file, true), true);
+                return new PrintWriterEventSender(writer);
+            } catch (Exception ex) {
+                //stick with default
+            }
+        }
+        return null;
+    }
+    
     private void addLoggingSupport(Endpoint endpoint, Bus bus, Logging annotation) {
         if (annotation != null) {
             LoggingFeature lf = new LoggingFeature();
@@ -85,19 +108,13 @@ public class LoggingFactoryBeanListener implements FactoryBeanListener {
             lf.setLimit(annotation.limit());
             lf.setLogBinary(annotation.showBinary());
             
-            if ("<stdout>".equals(annotation.outLocation())) {
-                lf.setOutSender(new PrintWriterEventSender(System.out));
-            } else if ("<stderr>".equals(annotation.outLocation())) {
-                lf.setOutSender(new PrintWriterEventSender(System.err));                
-            } else if (annotation.outLocation().startsWith("file:")) {
-                try {
-                    URI uri = new URI(annotation.outLocation());
-                    File file = new File(uri);
-                    PrintWriter writer = new PrintWriter(new FileWriter(file, true), true);
-                    lf.setOutSender(new PrintWriterEventSender(writer));
-                } catch (Exception ex) {
-                    //stick with default
-                }
+            LogEventSender les = createEventSender(annotation.outLocation());
+            if (les != null) {
+                lf.setOutSender(les);
+            }
+            les = createEventSender(annotation.inLocation());
+            if (les != null) {
+                lf.setInSender(les);
             }
             lf.initialize(endpoint, bus);
         }