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 2015/11/06 08:31:56 UTC

[09/10] camel git commit: CAMEL-9286: Log component should include log formatter options in component docs.

CAMEL-9286: Log component should include log formatter options in component docs.


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

Branch: refs/heads/camel-2.16.x
Commit: ed9c9f458ba55f689d659a6a3192bee98cba1310
Parents: 22ccfd7
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Nov 5 21:58:08 2015 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Nov 6 08:34:48 2015 +0100

----------------------------------------------------------------------
 .../camel/component/log/LogComponent.java       |  2 +-
 .../apache/camel/component/log/LogEndpoint.java |  6 ++
 .../processor/DefaultExchangeFormatter.java     | 77 ++++++++++++++++++--
 3 files changed, 76 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ed9c9f45/camel-core/src/main/java/org/apache/camel/component/log/LogComponent.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/log/LogComponent.java b/camel-core/src/main/java/org/apache/camel/component/log/LogComponent.java
index 8e506a0..d524654 100644
--- a/camel-core/src/main/java/org/apache/camel/component/log/LogComponent.java
+++ b/camel-core/src/main/java/org/apache/camel/component/log/LogComponent.java
@@ -73,7 +73,7 @@ public class LogComponent extends UriEndpointComponent {
         if (localFormatter != null) {
             setProperties(localFormatter, parameters);
         } else if (localFormatter == null && exchangeFormatter != null) {
-            // do not set properties, the exchangeFormatter is explicitly set, thefore the 
+            // do not set properties, the exchangeFormatter is explicitly set, therefore the
             // user would have set its properties explicitly too
             localFormatter = exchangeFormatter;
         } else {

http://git-wip-us.apache.org/repos/asf/camel/blob/ed9c9f45/camel-core/src/main/java/org/apache/camel/component/log/LogEndpoint.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/log/LogEndpoint.java b/camel-core/src/main/java/org/apache/camel/component/log/LogEndpoint.java
index f85103e..f89faed 100644
--- a/camel-core/src/main/java/org/apache/camel/component/log/LogEndpoint.java
+++ b/camel-core/src/main/java/org/apache/camel/component/log/LogEndpoint.java
@@ -22,11 +22,13 @@ import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.impl.ProcessorEndpoint;
 import org.apache.camel.processor.CamelLogProcessor;
+import org.apache.camel.processor.DefaultExchangeFormatter;
 import org.apache.camel.processor.ThroughputLogger;
 import org.apache.camel.spi.ExchangeFormatter;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriParams;
 import org.apache.camel.spi.UriPath;
 import org.apache.camel.util.CamelLogger;
 import org.apache.camel.util.ServiceHelper;
@@ -41,6 +43,7 @@ public class LogEndpoint extends ProcessorEndpoint {
     private volatile Processor logger;
     private Logger providedLogger;
     private ExchangeFormatter localFormatter;
+
     @UriPath(description = "Name of the logging category to use") @Metadata(required = "true")
     private String loggerName;
     @UriParam(defaultValue = "INFO", enums = "ERROR,WARN,INFO,DEBUG,TRACE,OFF")
@@ -55,6 +58,9 @@ public class LogEndpoint extends ProcessorEndpoint {
     private Boolean groupActiveOnly;
     @UriParam
     private Long groupDelay;
+    // we want to include the uri options of the DefaultExchangeFormatter
+    @UriParam
+    private DefaultExchangeFormatter exchangeFormatter;
 
     public LogEndpoint() {
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/ed9c9f45/camel-core/src/main/java/org/apache/camel/processor/DefaultExchangeFormatter.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/processor/DefaultExchangeFormatter.java b/camel-core/src/main/java/org/apache/camel/processor/DefaultExchangeFormatter.java
index 138c6cf..9b61b76 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/DefaultExchangeFormatter.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/DefaultExchangeFormatter.java
@@ -25,6 +25,8 @@ import java.util.concurrent.Future;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.spi.ExchangeFormatter;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriParams;
 import org.apache.camel.util.MessageHelper;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.StringHelper;
@@ -32,6 +34,7 @@ import org.apache.camel.util.StringHelper;
 /**
  * Default {@link ExchangeFormatter} that have fine grained options to configure what to include in the output.
  */
+@UriParams
 public class DefaultExchangeFormatter implements ExchangeFormatter {
 
     protected static final String LS = System.getProperty("line.separator");
@@ -39,23 +42,41 @@ public class DefaultExchangeFormatter implements ExchangeFormatter {
 
     public enum OutputStyle { Default, Tab, Fixed }
 
+    @UriParam(label = "formatting")
     private boolean showExchangeId;
+    @UriParam(label = "formatting", defaultValue = "true")
     private boolean showExchangePattern = true;
+    @UriParam(label = "formatting")
     private boolean showProperties;
+    @UriParam(label = "formatting")
     private boolean showHeaders;
+    @UriParam(label = "formatting", defaultValue = "true")
     private boolean skipBodyLineSeparator = true;
-    private boolean showBodyType = true;
+    @UriParam(label = "formatting", defaultValue = "true", description = "Show the message body.")
     private boolean showBody = true;
+    @UriParam(label = "formatting", defaultValue = "true")
+    private boolean showBodyType = true;
+    @UriParam(label = "formatting")
     private boolean showOut;
+    @UriParam(label = "formatting")
     private boolean showException;
+    @UriParam(label = "formatting")
     private boolean showCaughtException;
+    @UriParam(label = "formatting")
     private boolean showStackTrace;
+    @UriParam(label = "formatting")
     private boolean showAll;
+    @UriParam(label = "formatting")
     private boolean multiline;
+    @UriParam(label = "formatting")
     private boolean showFuture;
+    @UriParam(label = "formatting")
     private boolean showStreams;
+    @UriParam(label = "formatting")
     private boolean showFiles;
+    @UriParam(label = "formatting", defaultValue = "1000")
     private int maxChars = 10000;
+    @UriParam(label = "formatting", enums = "Default,Tab,Fixed", defaultValue = "Default")
     private OutputStyle style = OutputStyle.Default;
 
     private String style(String label) {
@@ -218,6 +239,9 @@ public class DefaultExchangeFormatter implements ExchangeFormatter {
         return showExchangeId;
     }
 
+    /**
+     * Show the unique exchange ID.
+     */
     public void setShowExchangeId(boolean showExchangeId) {
         this.showExchangeId = showExchangeId;
     }
@@ -226,6 +250,9 @@ public class DefaultExchangeFormatter implements ExchangeFormatter {
         return showProperties;
     }
 
+    /**
+     * Show the exchange properties.
+     */
     public void setShowProperties(boolean showProperties) {
         this.showProperties = showProperties;
     }
@@ -234,6 +261,9 @@ public class DefaultExchangeFormatter implements ExchangeFormatter {
         return showHeaders;
     }
 
+    /**
+     * Show the message headers.
+     */
     public void setShowHeaders(boolean showHeaders) {
         this.showHeaders = showHeaders;
     }
@@ -242,6 +272,11 @@ public class DefaultExchangeFormatter implements ExchangeFormatter {
         return skipBodyLineSeparator;
     }
 
+    /**
+     * Whether to skip line separators when logging the message body.
+     * This allows to log the message body in one line, setting this option to false will preserve any line separators
+     * from the body, which then will log the body as is.
+     */
     public void setSkipBodyLineSeparator(boolean skipBodyLineSeparator) {
         this.skipBodyLineSeparator = skipBodyLineSeparator;
     }
@@ -250,6 +285,9 @@ public class DefaultExchangeFormatter implements ExchangeFormatter {
         return showBodyType;
     }
 
+    /**
+     * Show the body Java type.
+     */
     public void setShowBodyType(boolean showBodyType) {
         this.showBodyType = showBodyType;
     }
@@ -258,6 +296,9 @@ public class DefaultExchangeFormatter implements ExchangeFormatter {
         return showBody;
     }
 
+    /*
+     * Show the message body.
+     */
     public void setShowBody(boolean showBody) {
         this.showBody = showBody;
     }
@@ -266,6 +307,9 @@ public class DefaultExchangeFormatter implements ExchangeFormatter {
         return showOut;
     }
 
+    /**
+     * If the exchange has an out message, show the out message.
+     */
     public void setShowOut(boolean showOut) {
         this.showOut = showOut;
     }
@@ -274,6 +318,9 @@ public class DefaultExchangeFormatter implements ExchangeFormatter {
         return showAll;
     }
 
+    /**
+     * Quick option for turning all options on. (multiline, maxChars has to be manually set if to be used)
+     */
     public void setShowAll(boolean showAll) {
         this.showAll = showAll;
     }
@@ -282,6 +329,9 @@ public class DefaultExchangeFormatter implements ExchangeFormatter {
         return showException;
     }
 
+    /**
+     * If the exchange has an exception, show the exception message (no stacktrace)
+     */
     public void setShowException(boolean showException) {
         this.showException = showException;
     }
@@ -290,6 +340,9 @@ public class DefaultExchangeFormatter implements ExchangeFormatter {
         return showStackTrace;
     }
 
+    /**
+     * Show the stack trace, if an exchange has an exception. Only effective if one of showAll, showException or showCaughtException are enabled.
+     */
     public void setShowStackTrace(boolean showStackTrace) {
         this.showStackTrace = showStackTrace;
     }
@@ -298,6 +351,11 @@ public class DefaultExchangeFormatter implements ExchangeFormatter {
         return showCaughtException;
     }
 
+    /**
+     * f the exchange has a caught exception, show the exception message (no stack trace).
+     * A caught exception is stored as a property on the exchange (using the key {@link org.apache.camel.Exchange#EXCEPTION_CAUGHT}
+     * and for instance a doCatch can catch exceptions.
+     */
     public void setShowCaughtException(boolean showCaughtException) {
         this.showCaughtException = showCaughtException;
     }
@@ -310,6 +368,9 @@ public class DefaultExchangeFormatter implements ExchangeFormatter {
         return maxChars;
     }
 
+    /**
+     * Limits the number of characters logged per line.
+     */
     public void setMaxChars(int maxChars) {
         this.maxChars = maxChars;
     }
@@ -327,8 +388,6 @@ public class DefaultExchangeFormatter implements ExchangeFormatter {
 
     /**
      * If enabled Camel will on Future objects wait for it to complete to obtain the payload to be logged.
-     * <p/>
-     * Is default disabled.
      */
     public void setShowFuture(boolean showFuture) {
         this.showFuture = showFuture;
@@ -338,6 +397,9 @@ public class DefaultExchangeFormatter implements ExchangeFormatter {
         return showExchangePattern;
     }
 
+    /**
+     * Shows the Message Exchange Pattern (or MEP for short).
+     */
     public void setShowExchangePattern(boolean showExchangePattern) {
         this.showExchangePattern = showExchangePattern;
     }
@@ -347,9 +409,10 @@ public class DefaultExchangeFormatter implements ExchangeFormatter {
     }
 
     /**
-     * If enabled Camel will output stream objects
-     * <p/>
-     * Is default disabled.
+     * Whether Camel should show stream bodies or not (eg such as java.io.InputStream).
+     * Beware if you enable this option then you may not be able later to access the message body
+     * as the stream have already been read by this logger.
+     * To remedy this you will have to use Stream Caching.
      */
     public void setShowStreams(boolean showStreams) {
         this.showStreams = showStreams;
@@ -361,8 +424,6 @@ public class DefaultExchangeFormatter implements ExchangeFormatter {
 
     /**
      * If enabled Camel will output files
-     * <p/>
-     * Is default disabled.
      */
     public void setShowFiles(boolean showFiles) {
         this.showFiles = showFiles;