You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2009/01/08 08:44:29 UTC

svn commit: r732629 - in /activemq/camel/branches/camel-1.x: ./ camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceFormatter.java camel-core/src/test/java/org/apache/camel/component/file/FileConfigureTest.java

Author: davsclaus
Date: Wed Jan  7 23:44:28 2009
New Revision: 732629

URL: http://svn.apache.org/viewvc?rev=732629&view=rev
Log:
Merged revisions 732625 via svnmerge from 
https://svn.apache.org/repos/asf/activemq/camel/trunk

........
  r732625 | davsclaus | 2009-01-08 08:02:54 +0100 (Thu, 08 Jan 2009) | 1 line
  
  CAMEL-1235: improvements to trace formatter.
........

Modified:
    activemq/camel/branches/camel-1.x/   (props changed)
    activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceFormatter.java
    activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/file/FileConfigureTest.java

Propchange: activemq/camel/branches/camel-1.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jan  7 23:44:28 2009
@@ -1 +1 @@
-/activemq/camel/trunk:709850,711200,711206,711219-711220,711523,711531,711756,711784,711859,711874,711962,711971,712064,712119,712148,712662,712692,712925,713013,713107,713136,713273,713290,713292,713295,713314,713475,713625,713932,713944,714032,717965,717989,718242,718273,718312-718515,719163-719184,719334,719339,719524,719662,719848,719851,719855,719864,719978-719979,720207,720435-720437,720806,721272,721331,721333-721334,721360,721669,721764,721813,721985,722005,722070,722110,722415,722438,722726,722845,722878,723264,723314,723325-723327,723409,723835,723966,724122,724619,724681,725040,725309-725320,725340,725351,725569-725572,725612,725652-725660,725715,725883,726339,726640-726645,726932,727113,727375,727377,727624,727713,727946,729401,729892,730069,730132,730154,730157,730275,730299,730504-730505,730508,730571,730599,730759,730903,730916,730923,730936,730992,731126,731168-731169,731488,731492,731799,731824,731836,731844,731860,732207,732210,732237,732246-732247,732378,7
 32589-732590
+/activemq/camel/trunk:709850,711200,711206,711219-711220,711523,711531,711756,711784,711859,711874,711962,711971,712064,712119,712148,712662,712692,712925,713013,713107,713136,713273,713290,713292,713295,713314,713475,713625,713932,713944,714032,717965,717989,718242,718273,718312-718515,719163-719184,719334,719339,719524,719662,719848,719851,719855,719864,719978-719979,720207,720435-720437,720806,721272,721331,721333-721334,721360,721669,721764,721813,721985,722005,722070,722110,722415,722438,722726,722845,722878,723264,723314,723325-723327,723409,723835,723966,724122,724619,724681,725040,725309-725320,725340,725351,725569-725572,725612,725652-725660,725715,725883,726339,726640-726645,726932,727113,727375,727377,727624,727713,727946,729401,729892,730069,730132,730154,730157,730275,730299,730504-730505,730508,730571,730599,730759,730903,730916,730923,730936,730992,731126,731168-731169,731488,731492,731799,731824,731836,731844,731860,732207,732210,732237,732246-732247,732378,7
 32589-732590,732625

Propchange: activemq/camel/branches/camel-1.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceFormatter.java
URL: http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceFormatter.java?rev=732629&r1=732628&r2=732629&view=diff
==============================================================================
--- activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceFormatter.java (original)
+++ activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceFormatter.java Wed Jan  7 23:44:28 2009
@@ -27,15 +27,17 @@
  * @version $Revision$
  */
 public class TraceFormatter {
+    private int breadCrumbLength;
     private boolean showBreadCrumb = true;
     private boolean showNode = true;
     private boolean showExchangeId;
+    private boolean showShortExchangeId;
     private boolean showExchangePattern = true;
     private boolean showProperties = true;
     private boolean showHeaders = true;
-    private boolean showBody = true;    
+    private boolean showBody = true;
     private boolean showBodyType = true;
-    private boolean showOutBody;    
+    private boolean showOutBody;
     private boolean showOutBodyType;
     private boolean showException = true;
 
@@ -167,6 +169,22 @@
         this.showException = showException;
     }
 
+    public int getBreadCrumbLength() {
+        return breadCrumbLength;
+    }
+
+    public void setBreadCrumbLength(int breadCrumbLength) {
+        this.breadCrumbLength = breadCrumbLength;
+    }
+
+    public boolean isShowShortExchangeId() {
+        return showShortExchangeId;
+    }
+
+    public void setShowShortExchangeId(boolean showShortExchangeId) {
+        this.showShortExchangeId = showShortExchangeId;
+    }
+
     // Implementation methods
     //-------------------------------------------------------------------------
     protected Object getBreadCrumbID(Exchange exchange) {
@@ -231,19 +249,36 @@
         String node = "";
         String result;
         
-        if (showBreadCrumb || showExchangeId) {
+        if (!showBreadCrumb && !showExchangeId && !showShortExchangeId && !showNode) {
+            return "";
+        }
+        
+        if (showBreadCrumb) {
             id = getBreadCrumbID(exchange).toString();
+        } else if (showExchangeId || showShortExchangeId) {
+            id = getBreadCrumbID(exchange).toString();
+            if (showShortExchangeId) {
+                // skip hostname for short exchange id
+                id = id.substring(id.indexOf("/") + 1);
+            }
         }
+
         if (showNode) {
             node = getNodeMessage(interceptor);
         }
+
         if (interceptor.shouldTraceOutExchanges() && exchange.getOut(false) != null) {
             result = node.trim() + " -> " + id.trim();
         } else {
             result = id.trim() + " -> " + node.trim();
         }
-        
-        // we want to ensure text coming after this is aligned for readability
-        return String.format("%1$-65.65s", result);
+
+        if (breadCrumbLength > 0) {
+            // we want to ensure text coming after this is aligned for readability
+            return String.format("%1$-" + breadCrumbLength + "." + breadCrumbLength + "s", result).trim();
+        } else {
+            return result.trim();
+        }
+
     }
 }

Modified: activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/file/FileConfigureTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/file/FileConfigureTest.java?rev=732629&r1=732628&r2=732629&view=diff
==============================================================================
--- activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/file/FileConfigureTest.java (original)
+++ activemq/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/file/FileConfigureTest.java Wed Jan  7 23:44:28 2009
@@ -61,6 +61,13 @@
         }
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        // one of the above tests created a /target folder in the root we want to get rid of when testing
+        deleteDirectory("/target");
+    }
+
     private FileConsumer createFileConsumer(String endpointUri) throws Exception {
         FileEndpoint endpoint = resolveMandatoryEndpoint(endpointUri, FileEndpoint.class);
         return (FileConsumer)endpoint.createConsumer(DUMMY_PROCESSOR);