camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1165232 - in /camel/trunk: camel-core/ camel-core/src/main/java/org/apache/camel/builder/ camel-core/src/main/java/org/apache/camel/component/dataset/ camel-core/src/main/java/org/apache/camel/component/log/ camel-core/src/main/java/org/ap...
Date Mon, 05 Sep 2011 10:35:37 GMT
Author: cschneider
Date: Mon Sep  5 10:35:35 2011
New Revision: 1165232

URL: http://svn.apache.org/viewvc?rev=1165232&view=rev
Log:
CAMEL-4414 Add new simpler CamelLogger in util and CamelLogProcessor in processor. Old CamelLogger stays in place for compatibility

Added:
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/CamelLogProcessor.java   (contents, props changed)
      - copied, changed from r1164512, camel/trunk/camel-core/src/main/java/org/apache/camel/processor/CamelLogger.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/CamelLogger.java
Modified:
    camel/trunk/camel-core/pom.xml
    camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DeadLetterChannelBuilder.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DefaultErrorHandlerBuilder.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/builder/LoggingErrorHandlerBuilder.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/dataset/DataSetConsumer.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/dataset/DataSetEndpoint.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/log/LogComponent.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/log/LogEndpoint.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/log/LogProducer.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockComponent.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/LoggingExceptionHandler.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ThrottlingInflightRoutePolicy.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/LogDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/CamelLogger.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DefaultErrorHandler.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LogProcessor.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LoggingErrorHandler.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ThroughputLogger.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceInterceptor.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Tracer.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/log/LogEndpointTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThroughPutLoggerTest.java
    camel/trunk/components/   (props changed)
    camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsEndpointConfigurationTest.java
    camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaConsumer.java
    camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaProducer.java
    camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java
    camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ServerChannelHandler.java
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandler.java
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandlerBuilder.java
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/log/SpringLogTest-context.xml
    camel/trunk/parent/pom.xml

Modified: camel/trunk/camel-core/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/pom.xml?rev=1165232&r1=1165231&r2=1165232&view=diff
==============================================================================
--- camel/trunk/camel-core/pom.xml (original)
+++ camel/trunk/camel-core/pom.xml Mon Sep  5 10:35:35 2011
@@ -91,6 +91,11 @@
       <scope>test</scope>
     </dependency>
 
+    <dependency>
+      <groupId>org.easymock</groupId>
+      <artifactId>easymock</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
 

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DeadLetterChannelBuilder.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DeadLetterChannelBuilder.java?rev=1165232&r1=1165231&r2=1165232&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DeadLetterChannelBuilder.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DeadLetterChannelBuilder.java Mon Sep  5 10:35:35 2011
@@ -21,11 +21,11 @@ import org.apache.camel.ExchangePattern;
 import org.apache.camel.LoggingLevel;
 import org.apache.camel.NoSuchEndpointException;
 import org.apache.camel.Processor;
-import org.apache.camel.processor.CamelLogger;
 import org.apache.camel.processor.DeadLetterChannel;
 import org.apache.camel.processor.RedeliveryPolicy;
 import org.apache.camel.processor.SendProcessor;
 import org.apache.camel.spi.RouteContext;
+import org.apache.camel.util.CamelLogger;
 import org.apache.camel.util.ObjectHelper;
 import org.slf4j.LoggerFactory;
 

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DefaultErrorHandlerBuilder.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DefaultErrorHandlerBuilder.java?rev=1165232&r1=1165231&r2=1165232&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DefaultErrorHandlerBuilder.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DefaultErrorHandlerBuilder.java Mon Sep  5 10:35:35 2011
@@ -16,21 +16,20 @@
  */
 package org.apache.camel.builder;
 
+import static org.apache.camel.builder.PredicateBuilder.toPredicate;
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
 import org.apache.camel.Expression;
 import org.apache.camel.LoggingLevel;
 import org.apache.camel.Predicate;
 import org.apache.camel.Processor;
-import org.apache.camel.processor.CamelLogger;
 import org.apache.camel.processor.DefaultErrorHandler;
 import org.apache.camel.processor.RedeliveryPolicy;
 import org.apache.camel.spi.Language;
 import org.apache.camel.spi.RouteContext;
+import org.apache.camel.util.CamelLogger;
 import org.slf4j.LoggerFactory;
 
-import static org.apache.camel.builder.PredicateBuilder.toPredicate;
-
 /**
  * The default error handler builder.
  *

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/LoggingErrorHandlerBuilder.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/LoggingErrorHandlerBuilder.java?rev=1165232&r1=1165231&r2=1165232&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/builder/LoggingErrorHandlerBuilder.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/builder/LoggingErrorHandlerBuilder.java Mon Sep  5 10:35:35 2011
@@ -18,9 +18,9 @@ package org.apache.camel.builder;
 
 import org.apache.camel.LoggingLevel;
 import org.apache.camel.Processor;
-import org.apache.camel.processor.CamelLogger;
 import org.apache.camel.processor.LoggingErrorHandler;
 import org.apache.camel.spi.RouteContext;
+import org.apache.camel.util.CamelLogger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/dataset/DataSetConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/dataset/DataSetConsumer.java?rev=1165232&r1=1165231&r2=1165232&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/dataset/DataSetConsumer.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/dataset/DataSetConsumer.java Mon Sep  5 10:35:35 2011
@@ -23,6 +23,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.impl.DefaultConsumer;
 import org.apache.camel.processor.ThroughputLogger;
+import org.apache.camel.util.CamelLogger;
 
 /**
  * DataSet consumer.
@@ -105,7 +106,8 @@ public class DataSetConsumer extends Def
     }
 
     protected ThroughputLogger createReporter() {
-        ThroughputLogger answer = new ThroughputLogger(endpoint.getEndpointUri(), (int) endpoint.getDataSet().getReportCount());
+        CamelLogger logger = new CamelLogger(endpoint.getEndpointUri());
+        ThroughputLogger answer = new ThroughputLogger(logger, (int) endpoint.getDataSet().getReportCount());
         answer.setAction("Sent");
         return answer;
     }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/dataset/DataSetEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/dataset/DataSetEndpoint.java?rev=1165232&r1=1165231&r2=1165232&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/dataset/DataSetEndpoint.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/dataset/DataSetEndpoint.java Mon Sep  5 10:35:35 2011
@@ -26,6 +26,7 @@ import org.apache.camel.Processor;
 import org.apache.camel.Service;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.processor.ThroughputLogger;
+import org.apache.camel.util.CamelLogger;
 import org.apache.camel.util.ExchangeHelper;
 import org.apache.camel.util.ObjectHelper;
 import org.slf4j.Logger;
@@ -208,7 +209,8 @@ public class DataSetEndpoint extends Moc
     }
 
     protected ThroughputLogger createReporter() {
-        ThroughputLogger answer = new ThroughputLogger(this.getEndpointUri(), (int) this.getDataSet().getReportCount());
+        CamelLogger logger = new CamelLogger(this.getEndpointUri());
+        ThroughputLogger answer = new ThroughputLogger(logger, (int) this.getDataSet().getReportCount());
         answer.setAction("Received");
         return answer;
     }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/log/LogComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/log/LogComponent.java?rev=1165232&r1=1165231&r2=1165232&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/log/LogComponent.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/log/LogComponent.java Mon Sep  5 10:35:35 2011
@@ -20,9 +20,11 @@ import java.util.Map;
 
 import org.apache.camel.Endpoint;
 import org.apache.camel.LoggingLevel;
+import org.apache.camel.Processor;
 import org.apache.camel.impl.DefaultComponent;
-import org.apache.camel.processor.CamelLogger;
+import org.apache.camel.processor.CamelLogProcessor;
 import org.apache.camel.processor.ThroughputLogger;
+import org.apache.camel.util.CamelLogger;
 import org.apache.camel.util.IntrospectionSupport;
 
 /**
@@ -38,20 +40,19 @@ public class LogComponent extends Defaul
         Integer groupSize = getAndRemoveParameter(parameters, "groupSize", Integer.class);
         Long groupInterval = getAndRemoveParameter(parameters, "groupInterval", Long.class);
 
-        CamelLogger logger;
+        CamelLogger camelLogger = new CamelLogger(remaining, level);
+        Processor logger;
         if (groupSize != null) {
-            logger = new ThroughputLogger(remaining, level, groupSize);
+            logger = new ThroughputLogger(camelLogger, groupSize);
         } else if (groupInterval != null) {
             Boolean groupActiveOnly = getAndRemoveParameter(parameters, "groupActiveOnly", Boolean.class, Boolean.TRUE);
             Long groupDelay = getAndRemoveParameter(parameters, "groupDelay", Long.class);
-            logger = new ThroughputLogger(this.getCamelContext(), remaining, level, groupInterval, groupDelay, groupActiveOnly);
+            logger = new ThroughputLogger(camelLogger, this.getCamelContext(), groupInterval, groupDelay, groupActiveOnly);
         } else {
             LogFormatter formatter = new LogFormatter();
             IntrospectionSupport.setProperties(formatter, parameters);
 
-            logger = new CamelLogger(remaining);
-            logger.setLevel(level);
-            logger.setFormatter(formatter);
+            logger = new CamelLogProcessor(camelLogger, formatter);
         }
 
         LogEndpoint endpoint = new LogEndpoint(uri, this);

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/log/LogEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/log/LogEndpoint.java?rev=1165232&r1=1165231&r2=1165232&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/log/LogEndpoint.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/log/LogEndpoint.java Mon Sep  5 10:35:35 2011
@@ -17,9 +17,9 @@
 package org.apache.camel.component.log;
 
 import org.apache.camel.Component;
+import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.impl.ProcessorEndpoint;
-import org.apache.camel.processor.CamelLogger;
 import org.apache.camel.util.ServiceHelper;
 
 /**
@@ -27,7 +27,7 @@ import org.apache.camel.util.ServiceHelp
  */
 public class LogEndpoint extends ProcessorEndpoint {
 
-    private CamelLogger logger;
+    private Processor logger;
 
     public LogEndpoint() {
     }
@@ -36,15 +36,11 @@ public class LogEndpoint extends Process
         super(endpointUri, component);
     }
 
-    public LogEndpoint(String endpointUri, Component component, CamelLogger logger) {
+    public LogEndpoint(String endpointUri, Component component, Processor logger) {
         super(endpointUri, component);
         setLogger(logger);
     }
     
-    public CamelLogger getLogger() {
-        return logger;
-    }
-
     @Override
     public void start() throws Exception {
         ServiceHelper.startService(logger);
@@ -55,7 +51,7 @@ public class LogEndpoint extends Process
         ServiceHelper.stopService(logger);
     }
     
-    public void setLogger(CamelLogger logger) {
+    public void setLogger(Processor logger) {
         this.logger = logger;
         // the logger is the processor
         setProcessor(this.logger);
@@ -63,7 +59,7 @@ public class LogEndpoint extends Process
 
     @Override
     public Producer createProducer() throws Exception {
-        return new LogProducer(this, getLogger());
+        return new LogProducer(this, this.logger);
     }
 
     @Override

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/log/LogProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/log/LogProducer.java?rev=1165232&r1=1165231&r2=1165232&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/log/LogProducer.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/log/LogProducer.java Mon Sep  5 10:35:35 2011
@@ -19,23 +19,28 @@ package org.apache.camel.component.log;
 import org.apache.camel.AsyncCallback;
 import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.impl.DefaultAsyncProducer;
-import org.apache.camel.processor.CamelLogger;
 
 /**
  * Log producer.
  */
 public class LogProducer extends DefaultAsyncProducer {
 
-    private final CamelLogger logger;
+    private final Processor logger;
 
-    public LogProducer(Endpoint endpoint, CamelLogger logger) {
+    public LogProducer(Endpoint endpoint, Processor logger) {
         super(endpoint);
         this.logger = logger;
     }
 
     public boolean process(Exchange exchange, AsyncCallback callback) {
-        logger.process(exchange);
+        try {
+            logger.process(exchange);
+        } catch (Exception e) {
+            throw new RuntimeCamelException(e);
+        }
         callback.done(true);
         return true;
     }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockComponent.java?rev=1165232&r1=1165231&r2=1165232&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockComponent.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockComponent.java Mon Sep  5 10:35:35 2011
@@ -22,6 +22,7 @@ import org.apache.camel.Endpoint;
 import org.apache.camel.Processor;
 import org.apache.camel.impl.DefaultComponent;
 import org.apache.camel.processor.ThroughputLogger;
+import org.apache.camel.util.CamelLogger;
 
 /**
  * A factory of {@link MockEndpoint} instances
@@ -35,7 +36,7 @@ public class MockComponent extends Defau
         MockEndpoint endpoint = new MockEndpoint(uri, this);
         Integer value = getAndRemoveParameter(parameters, "reportGroup", Integer.class);
         if (value != null) {
-            Processor reporter = new ThroughputLogger("org.apache.camel.component.mock:" + remaining, value);
+            Processor reporter = new ThroughputLogger(new CamelLogger("org.apache.camel.component.mock:" + remaining), value);
             endpoint.setReporter(reporter);
         }
         return endpoint;

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/LoggingExceptionHandler.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/LoggingExceptionHandler.java?rev=1165232&r1=1165231&r2=1165232&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/LoggingExceptionHandler.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/LoggingExceptionHandler.java Mon Sep  5 10:35:35 2011
@@ -20,8 +20,8 @@ import org.apache.camel.CamelExchangeExc
 import org.apache.camel.Exchange;
 import org.apache.camel.LoggingLevel;
 import org.apache.camel.RollbackExchangeException;
-import org.apache.camel.processor.CamelLogger;
 import org.apache.camel.spi.ExceptionHandler;
+import org.apache.camel.util.CamelLogger;
 import org.slf4j.LoggerFactory;
 
 /**

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ThrottlingInflightRoutePolicy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ThrottlingInflightRoutePolicy.java?rev=1165232&r1=1165231&r2=1165232&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ThrottlingInflightRoutePolicy.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ThrottlingInflightRoutePolicy.java Mon Sep  5 10:35:35 2011
@@ -30,8 +30,8 @@ import org.apache.camel.Exchange;
 import org.apache.camel.LoggingLevel;
 import org.apache.camel.Route;
 import org.apache.camel.management.event.ExchangeCompletedEvent;
-import org.apache.camel.processor.CamelLogger;
 import org.apache.camel.support.EventNotifierSupport;
+import org.apache.camel.util.CamelLogger;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.ServiceHelper;
 import org.slf4j.LoggerFactory;

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/LogDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/LogDefinition.java?rev=1165232&r1=1165231&r2=1165232&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/LogDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/LogDefinition.java Mon Sep  5 10:35:35 2011
@@ -24,9 +24,9 @@ import javax.xml.bind.annotation.XmlRoot
 import org.apache.camel.Expression;
 import org.apache.camel.LoggingLevel;
 import org.apache.camel.Processor;
-import org.apache.camel.processor.CamelLogger;
 import org.apache.camel.processor.LogProcessor;
 import org.apache.camel.spi.RouteContext;
+import org.apache.camel.util.CamelLogger;
 import org.apache.camel.util.ObjectHelper;
 
 /**

Copied: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/CamelLogProcessor.java (from r1164512, camel/trunk/camel-core/src/main/java/org/apache/camel/processor/CamelLogger.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/CamelLogProcessor.java?p2=camel/trunk/camel-core/src/main/java/org/apache/camel/processor/CamelLogProcessor.java&p1=camel/trunk/camel-core/src/main/java/org/apache/camel/processor/CamelLogger.java&r1=1164512&r2=1165232&rev=1165232&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/CamelLogger.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/CamelLogProcessor.java Mon Sep  5 10:35:35 2011
@@ -21,9 +21,7 @@ import org.apache.camel.LoggingLevel;
 import org.apache.camel.Processor;
 import org.apache.camel.impl.DefaultExchangeFormatter;
 import org.apache.camel.spi.ExchangeFormatter;
-import org.apache.camel.support.ServiceSupport;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.camel.util.CamelLogger;
 
 /**
  * A {@link Processor} which just logs to a {@link CamelLogger} object which can be used
@@ -34,33 +32,19 @@ import org.slf4j.LoggerFactory;
  *
  * @version 
  */
-public class CamelLogger extends ServiceSupport implements Processor {
-    private Logger log;
-    private LoggingLevel level;
+public class CamelLogProcessor implements Processor {
+    private CamelLogger log;
     private ExchangeFormatter formatter = DefaultExchangeFormatter.getInstance();
 
-    public CamelLogger() {
-        this(LoggerFactory.getLogger(CamelLogger.class));
+    public CamelLogProcessor() {
+        this(new CamelLogger(CamelLogProcessor.class.getName()));
     }
-
-    public CamelLogger(Logger log) {
-        this(log, LoggingLevel.INFO);
-    }
-
-    public CamelLogger(Logger log, LoggingLevel level) {
+    
+    public CamelLogProcessor(CamelLogger log) {
         this.log = log;
-        this.level = level;
-    }
-
-    public CamelLogger(String logName) {
-        this(LoggerFactory.getLogger(logName));
-    }
-
-    public CamelLogger(String logName, LoggingLevel level) {
-        this(LoggerFactory.getLogger(logName), level);
     }
 
-    public CamelLogger(Logger log, ExchangeFormatter formatter) {
+    public CamelLogProcessor(CamelLogger log, ExchangeFormatter formatter) {
         this(log);
         this.formatter = formatter;
     }
@@ -71,228 +55,34 @@ public class CamelLogger extends Service
     }
 
     public void process(Exchange exchange) {
-        switch (level) {
-        case DEBUG:
-            if (log.isDebugEnabled()) {
-                log.debug(logMessage(exchange));
-            }
-            break;
-        case ERROR:
-            if (log.isErrorEnabled()) {
-                log.error(logMessage(exchange));
-            }
-            break;
-        case INFO:
-            if (log.isInfoEnabled()) {
-                log.info(logMessage(exchange));
-            }
-            break;
-        case TRACE:
-            if (log.isTraceEnabled()) {
-                log.trace(logMessage(exchange));
-            }
-            break;
-        case WARN:
-            if (log.isWarnEnabled()) {
-                log.warn(logMessage(exchange));
-            }
-            break;
-        case OFF:
-            break;
-        default:
-            log.error("Unknown level: " + level + " when trying to log exchange: " + logMessage(exchange));
+        if (log.shouldLog()) {
+            log.log(formatter.format(exchange));
         }
     }
-
+    
     public void process(Exchange exchange, Throwable exception) {
-        switch (level) {
-        case DEBUG:
-            if (log.isDebugEnabled()) {
-                log.debug(logMessage(exchange), exception);
-            }
-            break;
-        case ERROR:
-            if (log.isErrorEnabled()) {
-                log.error(logMessage(exchange), exception);
-            }
-            break;
-        case INFO:
-            if (log.isInfoEnabled()) {
-                log.info(logMessage(exchange), exception);
-            }
-            break;
-        case TRACE:
-            if (log.isTraceEnabled()) {
-                log.trace(logMessage(exchange), exception);
-            }
-            break;
-        case WARN:
-            if (log.isWarnEnabled()) {
-                log.warn(logMessage(exchange), exception);
-            }
-            break;
-        case OFF:
-            break;
-        default:
-            log.error("Unknown level: " + level + " when trying to log exchange: " + logMessage(exchange));
+        if (log.shouldLog()) {
+            log.log(formatter.format(exchange), exception);
         }
     }
 
     public void process(Exchange exchange, String message) {
-        switch (level) {
-        case DEBUG:
-            if (log.isDebugEnabled()) {
-                log.debug(logMessage(exchange, message));
-            }
-            break;
-        case ERROR:
-            if (log.isErrorEnabled()) {
-                log.error(logMessage(exchange, message));
-            }
-            break;
-        case INFO:
-            if (log.isInfoEnabled()) {
-                log.info(logMessage(exchange, message));
-            }
-            break;
-        case TRACE:
-            if (log.isTraceEnabled()) {
-                log.trace(logMessage(exchange, message));
-            }
-            break;
-        case WARN:
-            if (log.isWarnEnabled()) {
-                log.warn(logMessage(exchange, message));
-            }
-            break;
-        case OFF:
-            break;
-        default:
-            log.error("Unknown level: " + level + " when trying to log exchange: " + logMessage(exchange, message));
+        if (log.shouldLog()) {
+            log.log(formatter.format(exchange) + message);
         }
     }
 
-    public void log(String message, LoggingLevel loggingLevel) {
-        LoggingLevel oldLogLevel = getLevel();
-        setLevel(loggingLevel);
-        log(message);
-        setLevel(oldLogLevel);
+    public CamelLogger getLogger() {
+        return log;
     }
     
-    public void log(String message) {
-        switch (level) {
-        case DEBUG:
-            if (log.isDebugEnabled()) {
-                log.debug(message);
-            }
-            break;
-        case ERROR:
-            if (log.isErrorEnabled()) {
-                log.error(message);
-            }
-            break;
-        case INFO:
-            if (log.isInfoEnabled()) {
-                log.info(message);
-            }
-            break;
-        case TRACE:
-            if (log.isTraceEnabled()) {
-                log.trace(message);
-            }
-            break;
-        case WARN:
-            if (log.isWarnEnabled()) {
-                log.warn(message);
-            }
-            break;
-        case OFF:
-            break;
-        default:
-            log.error("Unknown level: " + level + " when trying to log exchange: " + message);
-        }
+    public void setLogName(String logName) {
+        log.setLogName(logName);
     }
-
-    public void log(String message, Throwable exception, LoggingLevel loggingLevel) {
-        LoggingLevel oldLogLevel = getLevel();
-        setLevel(loggingLevel);
-        log(message, exception);
-        setLevel(oldLogLevel);
-    }   
     
-    public void log(String message, Throwable exception) {
-        switch (level) {
-        case DEBUG:
-            if (log.isDebugEnabled()) {
-                log.debug(message, exception);
-            }
-            break;
-        case ERROR:
-            if (log.isErrorEnabled()) {
-                log.error(message, exception);
-            }
-            break;
-        case INFO:
-            if (log.isInfoEnabled()) {
-                log.info(message, exception);
-            }
-            break;
-        case TRACE:
-            if (log.isTraceEnabled()) {
-                log.trace(message, exception);
-            }
-            break;
-        case WARN:
-            if (log.isWarnEnabled()) {
-                log.warn(message, exception);
-            }
-            break;
-        case OFF:
-            break;
-        default:
-            log.error("Unknown level: " + level + " when trying to log exchange: " + message, exception);
-        }
-    }
-
-    protected String logMessage(Exchange exchange) {
-        return formatter.format(exchange);
-    }
-
-    protected String logMessage(Exchange exchange, String message) {
-        return formatter.format(exchange) + message;
-    }
-
-    public Logger getLog() {
-        return log;
-    }
-
-    public void setLog(Logger log) {
-        this.log = log;
-    }
-
-    public LoggingLevel getLevel() {
-        return level;
-    }
-
     public void setLevel(LoggingLevel level) {
-        this.level = level;
+        log.setLevel(level);
     }
 
-    public void setFormatter(ExchangeFormatter formatter) {
-        this.formatter = formatter;
-    }
 
-    public void setLogName(String logName) {
-        this.log = LoggerFactory.getLogger(logName);
-    }
-
-    @Override
-    protected void doStart() throws Exception {
-        // noop
-    }
-
-    @Override
-    protected void doStop() throws Exception {
-        // noop
-    }
 }

Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/CamelLogProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/CamelLogProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/CamelLogProcessor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/CamelLogger.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/CamelLogger.java?rev=1165232&r1=1165231&r2=1165232&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/CamelLogger.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/CamelLogger.java Mon Sep  5 10:35:35 2011
@@ -32,8 +32,9 @@ import org.slf4j.LoggerFactory;
  * The name <tt>CamelLogger</tt> has been chosen to avoid any name clash with log kits
  * which has a <tt>Logger</tt> class.
  *
- * @version 
+ * @deprecated This class has been split up into org.apache.camel.util.CamelLogger and org.apache.camel.processor.CamelLogProcessor 
  */
+@Deprecated
 public class CamelLogger extends ServiceSupport implements Processor {
     private Logger log;
     private LoggingLevel level;

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java?rev=1165232&r1=1165231&r2=1165232&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java Mon Sep  5 10:35:35 2011
@@ -23,6 +23,7 @@ import org.apache.camel.Processor;
 import org.apache.camel.builder.ExpressionBuilder;
 import org.apache.camel.builder.PredicateBuilder;
 import org.apache.camel.processor.exceptionpolicy.ExceptionPolicyStrategy;
+import org.apache.camel.util.CamelLogger;
 
 /**
  * Implements a <a

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DefaultErrorHandler.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DefaultErrorHandler.java?rev=1165232&r1=1165231&r2=1165232&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DefaultErrorHandler.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DefaultErrorHandler.java Mon Sep  5 10:35:35 2011
@@ -21,6 +21,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Predicate;
 import org.apache.camel.Processor;
 import org.apache.camel.processor.exceptionpolicy.ExceptionPolicyStrategy;
+import org.apache.camel.util.CamelLogger;
 
 /**
  * Default error handler

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LogProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LogProcessor.java?rev=1165232&r1=1165231&r2=1165232&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LogProcessor.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LogProcessor.java Mon Sep  5 10:35:35 2011
@@ -21,6 +21,7 @@ import org.apache.camel.AsyncProcessor;
 import org.apache.camel.Exchange;
 import org.apache.camel.Expression;
 import org.apache.camel.util.AsyncProcessorHelper;
+import org.apache.camel.util.CamelLogger;
 
 /**
  * A processor which evaluates an Expression and logs it.

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LoggingErrorHandler.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LoggingErrorHandler.java?rev=1165232&r1=1165231&r2=1165232&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LoggingErrorHandler.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LoggingErrorHandler.java Mon Sep  5 10:35:35 2011
@@ -19,6 +19,7 @@ package org.apache.camel.processor;
 import org.apache.camel.CamelContext;
 import org.apache.camel.Processor;
 import org.apache.camel.processor.exceptionpolicy.ExceptionPolicyStrategy;
+import org.apache.camel.util.CamelLogger;
 
 /**
  * An {@link ErrorHandler} which uses commons-logging to dump the error

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java?rev=1165232&r1=1165231&r2=1165232&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java Mon Sep  5 10:35:35 2011
@@ -34,6 +34,7 @@ import org.apache.camel.model.OnExceptio
 import org.apache.camel.spi.SubUnitOfWorkCallback;
 import org.apache.camel.util.AsyncProcessorHelper;
 import org.apache.camel.util.CamelContextHelper;
+import org.apache.camel.util.CamelLogger;
 import org.apache.camel.util.EventHelper;
 import org.apache.camel.util.ExchangeHelper;
 import org.apache.camel.util.MessageHelper;

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ThroughputLogger.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ThroughputLogger.java?rev=1165232&r1=1165231&r2=1165232&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ThroughputLogger.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ThroughputLogger.java Mon Sep  5 10:35:35 2011
@@ -23,7 +23,9 @@ import java.util.concurrent.atomic.Atomi
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
-import org.apache.camel.LoggingLevel;
+import org.apache.camel.Processor;
+import org.apache.camel.support.ServiceSupport;
+import org.apache.camel.util.CamelLogger;
 import org.apache.camel.util.ObjectHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -33,7 +35,7 @@ import org.slf4j.LoggerFactory;
  *
  * @version 
  */
-public class ThroughputLogger extends CamelLogger {
+public class ThroughputLogger extends ServiceSupport implements Processor {
     private static final Logger LOG = LoggerFactory.getLogger(ThroughputLogger.class);
 
     private final AtomicInteger receivedCounter = new AtomicInteger();
@@ -46,38 +48,21 @@ public class ThroughputLogger extends Ca
     private long startTime;
     private long groupStartTime;
     private String action = "Received";
-    private String logMessage;
     private CamelContext camelContext;
     private ScheduledExecutorService logSchedulerService;
+    private CamelLogger log;
 
-    public ThroughputLogger() {
+    public ThroughputLogger(CamelLogger log) {
+        this.log = log;
     }
 
-    public ThroughputLogger(Logger log) {
-        super(log);
-    }
-
-    public ThroughputLogger(Logger log, LoggingLevel level) {
-        super(log, level);
-    }
-
-    public ThroughputLogger(String logName) {
-        super(logName);
-    }
-
-    public ThroughputLogger(String logName, LoggingLevel level) {
-        super(logName, level);
-    }
-
-    public ThroughputLogger(String logName, LoggingLevel level, Integer groupSize) {
-        super(logName, level);
+    public ThroughputLogger(CamelLogger log, Integer groupSize) {
+        this(log);
         setGroupSize(groupSize);
     }
 
-    public ThroughputLogger(CamelContext camelContext, String logName, LoggingLevel level,
-                            Long groupInterval, Long groupDelay, Boolean groupActiveOnly) {
-        super(logName, level);
-
+    public ThroughputLogger(CamelLogger log, CamelContext camelContext, Long groupInterval, Long groupDelay, Boolean groupActiveOnly) {
+        this(log);
         this.camelContext = camelContext;
         setGroupInterval(groupInterval);
         setGroupActiveOnly(groupActiveOnly);
@@ -86,15 +71,6 @@ public class ThroughputLogger extends Ca
         }
     }
 
-    public ThroughputLogger(String logName, int groupSize) {
-        super(logName);
-        setGroupSize(groupSize);
-    }
-
-    public ThroughputLogger(int groupSize) {
-        setGroupSize(groupSize);
-    }
-
     @Override
     public void process(Exchange exchange) {
         if (startTime == 0) {
@@ -105,8 +81,7 @@ public class ThroughputLogger extends Ca
         //only process if groupSize is set...otherwise we're in groupInterval mode
         if (groupSize != null) {
             if (receivedCount % groupSize == 0) {
-                logMessage = createLogMessage(exchange, receivedCount);
-                super.process(exchange);
+                log.log(createLogMessage(exchange, receivedCount));
             }
         }
     }
@@ -164,14 +139,9 @@ public class ThroughputLogger extends Ca
     public void setAction(String action) {
         this.action = action;
     }
-
-    @Override
-    protected String logMessage(Exchange exchange) {
-        return logMessage;
-    }
-
+    
     @Override
-    public void start() throws Exception {
+    public void doStart() throws Exception {
         // if an interval was specified, create a background thread
         if (groupInterval != null) {
             ObjectHelper.notNull(camelContext, "CamelContext", this);
@@ -185,7 +155,7 @@ public class ThroughputLogger extends Ca
     }
 
     @Override
-    public void stop() throws Exception {
+    public void doStop() throws Exception {
         if (logSchedulerService != null) {
             camelContext.getExecutorServiceManager().shutdownNow(logSchedulerService);
             logSchedulerService = null;
@@ -255,7 +225,7 @@ public class ThroughputLogger extends Ca
         String message = getAction() + ": " + currentCount + " new messages, with total " + receivedCount + " so far. Last group took: " + duration
                 + " millis which is: " + numberFormat.format(rate)
                 + " messages per second. average: " + numberFormat.format(average);
-        log(message);
+        log.log(message);
     }
 
     protected double messagesPerSecond(long messageCount, long startTime, long endTime) {

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceInterceptor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceInterceptor.java?rev=1165232&r1=1165231&r2=1165232&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceInterceptor.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceInterceptor.java Mon Sep  5 10:35:35 2011
@@ -40,7 +40,7 @@ import org.apache.camel.model.OnCompleti
 import org.apache.camel.model.OnExceptionDefinition;
 import org.apache.camel.model.ProcessorDefinition;
 import org.apache.camel.model.ProcessorDefinitionHelper;
-import org.apache.camel.processor.CamelLogger;
+import org.apache.camel.processor.CamelLogProcessor;
 import org.apache.camel.processor.DelegateAsyncProcessor;
 import org.apache.camel.spi.ExchangeFormatter;
 import org.apache.camel.spi.InterceptStrategy;
@@ -60,7 +60,7 @@ import org.slf4j.LoggerFactory;
 public class TraceInterceptor extends DelegateAsyncProcessor implements ExchangeFormatter {
     private static final transient Logger LOG = LoggerFactory.getLogger(TraceInterceptor.class);
 
-    private CamelLogger logger;
+    private CamelLogProcessor logger;
     private Producer traceEventProducer;
     private final ProcessorDefinition node;
     private final Tracer tracer;
@@ -276,7 +276,7 @@ public class TraceInterceptor extends De
         return node;
     }
 
-    public CamelLogger getLogger() {
+    public CamelLogProcessor getLogger() {
         return logger;
     }
 

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Tracer.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Tracer.java?rev=1165232&r1=1165231&r2=1165232&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Tracer.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Tracer.java Mon Sep  5 10:35:35 2011
@@ -26,10 +26,10 @@ import org.apache.camel.Processor;
 import org.apache.camel.Service;
 import org.apache.camel.model.ProcessorDefinition;
 import org.apache.camel.model.RouteDefinitionHelper;
-import org.apache.camel.processor.CamelLogger;
+import org.apache.camel.processor.CamelLogProcessor;
 import org.apache.camel.spi.ExchangeFormatter;
 import org.apache.camel.spi.InterceptStrategy;
-import org.slf4j.LoggerFactory;
+import org.apache.camel.util.CamelLogger;
 
 /**
  * An interceptor strategy for tracing routes
@@ -51,7 +51,7 @@ public class Tracer implements Intercept
     private String destinationUri;
     private Endpoint destination;
     private boolean useJpa;
-    private CamelLogger logger;
+    private CamelLogProcessor logger;
     private TraceInterceptorFactory traceInterceptorFactory = new DefaultTraceInterceptorFactory();
     private TraceEventHandler traceHandler;
     private String jpaTraceEventMessageClassName = JPA_TRACE_EVENT_MESSAGE;
@@ -93,10 +93,9 @@ public class Tracer implements Intercept
      * @param formatter the exchange formatter
      * @return the logger to use
      */
-    public synchronized CamelLogger getLogger(ExchangeFormatter formatter) {
+    public synchronized CamelLogProcessor getLogger(ExchangeFormatter formatter) {
         if (logger == null) {
-            logger = new CamelLogger(LoggerFactory.getLogger(getLogName()), formatter);
-            logger.setLevel(getLogLevel());
+            logger = new CamelLogProcessor(new CamelLogger(getLogName(), getLogLevel()), formatter);
         }
         return logger;
     }
@@ -165,7 +164,7 @@ public class Tracer implements Intercept
         this.logLevel = logLevel;
         // update logger if its in use
         if (logger != null) {
-            logger.setLevel(logLevel);
+            logger.getLogger().setLevel(logLevel);
         }
     }
 
@@ -203,7 +202,7 @@ public class Tracer implements Intercept
         this.logName = logName;
         // update logger if its in use
         if (logger != null) {
-            logger.setLogName(logName);
+            logger.getLogger().setLogName(logName);
         }
     }
 

Added: camel/trunk/camel-core/src/main/java/org/apache/camel/util/CamelLogger.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/CamelLogger.java?rev=1165232&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/CamelLogger.java (added)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/CamelLogger.java Mon Sep  5 10:35:35 2011
@@ -0,0 +1,168 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.util;
+
+import org.apache.camel.LoggingLevel;
+import org.apache.camel.Processor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A {@link Processor} which just logs to a {@link CamelLogger} object which can be used
+ * as an exception handler instead of using a dead letter queue.
+ * <p/>
+ * The name <tt>CamelLogger</tt> has been chosen to avoid any name clash with log kits
+ * which has a <tt>Logger</tt> class.
+ *
+ * @version 
+ */
+public class CamelLogger {
+    private Logger log;
+    private LoggingLevel level;
+
+    public CamelLogger() {
+        this(LoggerFactory.getLogger(CamelLogger.class));
+    }
+
+    public CamelLogger(Logger log) {
+        this(log, LoggingLevel.INFO);
+    }
+
+    public CamelLogger(Logger log, LoggingLevel level) {
+        this.log = log;
+        this.level = level;
+    }
+
+    public CamelLogger(String logName) {
+        this(LoggerFactory.getLogger(logName));
+    }
+
+    public CamelLogger(String logName, LoggingLevel level) {
+        this(LoggerFactory.getLogger(logName), level);
+    }
+
+    @Override
+    public String toString() {
+        return "Logger[" + log + "]";
+    }
+
+    public void log(String message, LoggingLevel loggingLevel) {
+        LoggingLevel oldLogLevel = getLevel();
+        setLevel(loggingLevel);
+        log(message);
+        setLevel(oldLogLevel);
+    }
+    
+    public void log(String message) {
+        if (shouldLog(log, level)) {
+            log(log, level,message);
+        }
+    }
+
+    public void log(String message, Throwable exception, LoggingLevel loggingLevel) {
+        log(log, loggingLevel, message, exception);
+    }   
+    
+    public void log(String message, Throwable exception) {
+        if (shouldLog(log, level)) {
+            log(log, level, message, exception);
+        }
+    }
+
+    public Logger getLog() {
+        return log;
+    }
+
+    public void setLog(Logger log) {
+        this.log = log;
+    }
+
+    public LoggingLevel getLevel() {
+        return level;
+    }
+
+    public void setLevel(LoggingLevel level) {
+        this.level = level;
+    }
+
+    public void setLogName(String logName) {
+        this.log = LoggerFactory.getLogger(logName);
+    }
+
+    public static boolean shouldLog(Logger log, LoggingLevel level) {
+        if (level == null) {
+            throw new NullPointerException("Log level may not be null");
+        }
+        return level == LoggingLevel.DEBUG && log.isDebugEnabled() 
+            || level == LoggingLevel.ERROR && log.isErrorEnabled()
+            || level == LoggingLevel.INFO && log.isInfoEnabled()
+            || level == LoggingLevel.TRACE && log.isTraceEnabled()
+            || level == LoggingLevel.WARN && log.isWarnEnabled();
+    }
+
+    public static void log(Logger log, LoggingLevel level, String message) {
+        if (level == null) {
+            throw new NullPointerException("Log level may not be null");
+        }
+        switch (level) {
+        case DEBUG:
+            log.debug(message);
+            break;
+        case ERROR:
+            log.error(message);
+            break;
+        case INFO:
+            log.info(message);
+            break;
+        case TRACE:
+            log.trace(message);
+            break;
+        case WARN:
+            log.warn(message);
+            break;
+        }
+    }
+    
+    public static void log(Logger log, LoggingLevel level, String message, Throwable th) {
+        if (level == null) {
+            throw new NullPointerException("Log level may not be null");
+        }
+        switch (level) {
+        case DEBUG:
+            log.debug(message, th);
+            break;
+        case ERROR:
+            log.error(message, th);
+            break;
+        case INFO:
+            log.info(message, th);
+            break;
+        case TRACE:
+            log.trace(message, th);
+            break;
+        case WARN:
+            log.warn(message, th);
+            break;
+        }
+    }
+
+    public boolean shouldLog() {
+        return CamelLogger.shouldLog(log, level);
+    }
+
+}

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/log/LogEndpointTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/log/LogEndpointTest.java?rev=1165232&r1=1165231&r2=1165232&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/log/LogEndpointTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/log/LogEndpointTest.java Mon Sep  5 10:35:35 2011
@@ -20,7 +20,7 @@ import org.apache.camel.ContextTestSuppo
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.processor.CamelLogger;
+import org.apache.camel.processor.CamelLogProcessor;
 
 /**
  * @version 
@@ -29,7 +29,7 @@ public class LogEndpointTest extends Con
 
     private static Exchange logged;
 
-    private static class MyLogger extends CamelLogger {
+    private static class MyLogger extends CamelLogProcessor {
 
         @Override
         public void process(Exchange exchange) {
@@ -64,7 +64,6 @@ public class LogEndpointTest extends Con
                 end.setLogger(new MyLogger());
 
                 assertEquals("log:myLogger", end.getEndpointUri());
-                assertNotNull(end.getLogger());
 
                 from("direct:start").to(end).to("mock:result");
             }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThroughPutLoggerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThroughPutLoggerTest.java?rev=1165232&r1=1165231&r2=1165232&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThroughPutLoggerTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThroughPutLoggerTest.java Mon Sep  5 10:35:35 2011
@@ -16,16 +16,27 @@
  */
 package org.apache.camel.processor;
 
+import org.apache.camel.util.CamelLogger;
+import org.easymock.EasyMock;
+import org.slf4j.Logger;
 import junit.framework.TestCase;
 
 public class ThroughPutLoggerTest extends TestCase {
 
     public void testLogStringDurationIsNotZero() throws Exception {
-        ThroughputLogger underTest = new ThroughputLogger(10);
+        Logger logger = EasyMock.createMock(Logger.class);
+        logger.isInfoEnabled();
+        EasyMock.expectLastCall().andReturn(true).atLeastOnce();
+        logger.info(EasyMock.startsWith("Received: 10"));
+        EasyMock.expectLastCall().once();
+        logger.info(EasyMock.startsWith("Received: 20"));
+        EasyMock.expectLastCall().once();
+        EasyMock.replay(logger);
+        ThroughputLogger underTest = new ThroughputLogger(new CamelLogger(logger));
+        underTest.setGroupSize(10);
         for (int i = 0; i < 25; i++) {
             underTest.process(null);
         }
-        String message = (String) underTest.logMessage(null);
-        assertTrue("consumed 20 :" + message, message.contains("20"));
+        EasyMock.verify(logger);
     }
 }

Propchange: camel/trunk/components/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Mon Sep  5 10:35:35 2011
@@ -1 +1,3 @@
 target
+.project
+.settings

Modified: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsEndpointConfigurationTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsEndpointConfigurationTest.java?rev=1165232&r1=1165231&r2=1165232&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsEndpointConfigurationTest.java (original)
+++ camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsEndpointConfigurationTest.java Mon Sep  5 10:35:35 2011
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.component.jms;
 
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
+
 import javax.jms.ConnectionFactory;
 import javax.jms.DeliveryMode;
 import javax.jms.ExceptionListener;
@@ -28,7 +30,6 @@ import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.ResolveEndpointFailedException;
 import org.apache.camel.impl.JndiRegistry;
-import org.apache.camel.processor.CamelLogger;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 import org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter;
@@ -40,13 +41,18 @@ import org.springframework.jms.listener.
 import org.springframework.jms.support.converter.SimpleMessageConverter;
 import org.springframework.util.ErrorHandler;
 
-import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
-
 /**
  * @version 
  */
 public class JmsEndpointConfigurationTest extends CamelTestSupport {
 
+    private final class FailProcessor implements Processor {
+        @Override
+        public void process(Exchange exchange) throws Exception {
+            fail("Should not be reached");
+        }
+    }
+
     private ConnectionFactory cf = new ActiveMQConnectionFactory("vm:myBroker");
 
     private Processor dummyProcessor = new Processor() {
@@ -182,7 +188,7 @@ public class JmsEndpointConfigurationTes
     public void testInvalidMaxConcurrentConsumers() throws Exception {
         JmsEndpoint endpoint = (JmsEndpoint) resolveMandatoryEndpoint("jms:queue:Foo?concurrentConsumers=5&maxConcurrentConsumers=2");
         try {
-            endpoint.createConsumer(new CamelLogger());
+            endpoint.createConsumer(new FailProcessor());
             fail("Should have thrown exception");
         } catch (IllegalArgumentException e) {
             assertEquals("Property maxConcurrentConsumers: 2 must be higher than concurrentConsumers: 5", e.getMessage());
@@ -194,7 +200,7 @@ public class JmsEndpointConfigurationTes
         JmsEndpoint endpoint = (JmsEndpoint) resolveMandatoryEndpoint("jms:queue:Foo?concurrentConsumers=5&maxConcurrentConsumers=2&consumerType=Simple");
 
         try {
-            endpoint.createConsumer(new CamelLogger());
+            endpoint.createConsumer(new FailProcessor());
             fail("Should have thrown exception");
         } catch (IllegalArgumentException e) {
             assertEquals("Property maxConcurrentConsumers: 2 must be higher than concurrentConsumers: 5", e.getMessage());

Modified: camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaConsumer.java?rev=1165232&r1=1165231&r2=1165232&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaConsumer.java (original)
+++ camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaConsumer.java Mon Sep  5 10:35:35 2011
@@ -23,7 +23,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.converter.IOConverter;
 import org.apache.camel.impl.DefaultConsumer;
-import org.apache.camel.processor.CamelLogger;
+import org.apache.camel.util.CamelLogger;
 import org.apache.camel.util.ExchangeHelper;
 import org.apache.mina.common.IoAcceptor;
 import org.apache.mina.common.IoHandler;

Modified: camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaProducer.java?rev=1165232&r1=1165231&r2=1165232&view=diff
==============================================================================
--- camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaProducer.java (original)
+++ camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaProducer.java Mon Sep  5 10:35:35 2011
@@ -26,7 +26,7 @@ import org.apache.camel.ExchangeTimedOut
 import org.apache.camel.ServicePoolAware;
 import org.apache.camel.converter.IOConverter;
 import org.apache.camel.impl.DefaultProducer;
-import org.apache.camel.processor.CamelLogger;
+import org.apache.camel.util.CamelLogger;
 import org.apache.camel.util.ExchangeHelper;
 import org.apache.mina.common.ConnectFuture;
 import org.apache.mina.common.IoConnector;

Modified: camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java?rev=1165232&r1=1165231&r2=1165232&view=diff
==============================================================================
--- camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java (original)
+++ camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java Mon Sep  5 10:35:35 2011
@@ -29,7 +29,7 @@ import org.apache.camel.ServicePoolAware
 import org.apache.camel.converter.IOConverter;
 import org.apache.camel.impl.DefaultAsyncProducer;
 import org.apache.camel.impl.DefaultExchange;
-import org.apache.camel.processor.CamelLogger;
+import org.apache.camel.util.CamelLogger;
 import org.apache.camel.util.ExchangeHelper;
 import org.jboss.netty.bootstrap.ClientBootstrap;
 import org.jboss.netty.bootstrap.ConnectionlessBootstrap;

Modified: camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ServerChannelHandler.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ServerChannelHandler.java?rev=1165232&r1=1165231&r2=1165232&view=diff
==============================================================================
--- camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ServerChannelHandler.java (original)
+++ camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ServerChannelHandler.java Mon Sep  5 10:35:35 2011
@@ -23,7 +23,7 @@ import org.apache.camel.component.netty.
 import org.apache.camel.component.netty.NettyHelper;
 import org.apache.camel.component.netty.NettyPayloadHelper;
 import org.apache.camel.converter.IOConverter;
-import org.apache.camel.processor.CamelLogger;
+import org.apache.camel.util.CamelLogger;
 import org.apache.camel.util.ExchangeHelper;
 import org.jboss.netty.channel.ChannelHandler;
 import org.jboss.netty.channel.ChannelHandlerContext;

Modified: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandler.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandler.java?rev=1165232&r1=1165231&r2=1165232&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandler.java (original)
+++ camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandler.java Mon Sep  5 10:35:35 2011
@@ -21,10 +21,10 @@ import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
 import org.apache.camel.Predicate;
 import org.apache.camel.Processor;
-import org.apache.camel.processor.CamelLogger;
 import org.apache.camel.processor.RedeliveryErrorHandler;
 import org.apache.camel.processor.RedeliveryPolicy;
 import org.apache.camel.processor.exceptionpolicy.ExceptionPolicyStrategy;
+import org.apache.camel.util.CamelLogger;
 import org.apache.camel.util.ObjectHelper;
 import org.springframework.transaction.TransactionDefinition;
 import org.springframework.transaction.TransactionStatus;

Modified: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandlerBuilder.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandlerBuilder.java?rev=1165232&r1=1165231&r2=1165232&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandlerBuilder.java (original)
+++ camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandlerBuilder.java Mon Sep  5 10:35:35 2011
@@ -21,9 +21,9 @@ import java.util.Map;
 import org.apache.camel.LoggingLevel;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.DefaultErrorHandlerBuilder;
-import org.apache.camel.processor.CamelLogger;
 import org.apache.camel.spi.RouteContext;
 import org.apache.camel.spi.TransactedPolicy;
+import org.apache.camel.util.CamelLogger;
 import org.apache.camel.util.ObjectHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

Modified: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/log/SpringLogTest-context.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/log/SpringLogTest-context.xml?rev=1165232&r1=1165231&r2=1165232&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/log/SpringLogTest-context.xml (original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/log/SpringLogTest-context.xml Mon Sep  5 10:35:35 2011
@@ -26,7 +26,7 @@
         <property name="logger" ref="myLogger"/>
     </bean>
 
-    <bean id="myLogger" class="org.apache.camel.processor.CamelLogger">
+    <bean id="myLogger" class="org.apache.camel.processor.CamelLogProcessor">
         <property name="level" value="WARN"/>
         <property name="logName" value="cool"/>
     </bean>

Modified: camel/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/parent/pom.xml?rev=1165232&r1=1165231&r2=1165232&view=diff
==============================================================================
--- camel/trunk/parent/pom.xml (original)
+++ camel/trunk/parent/pom.xml Mon Sep  5 10:35:35 2011
@@ -1286,6 +1286,11 @@
       </dependency>
       <dependency>
         <groupId>org.easymock</groupId>
+        <artifactId>easymock</artifactId>
+        <version>${easymock-version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.easymock</groupId>
         <artifactId>easymockclassextension</artifactId>
         <version>${easymock-version}</version>
       </dependency>



Mime
View raw message