This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit f721dec6291e358f694b90d0e78292329aa4e9e8
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon May 18 12:38:54 2020 +0200

    CAMEL-15045: Allow to configure route startup logging level. For example if 
you have 100+ routes it may be annoying with a log per route.
---
 .../MainConfigurationPropertiesConfigurer.java     |  5 +++++
 .../camel-main-configuration-metadata.json         |  1 +
 .../camel/main/DefaultConfigurationConfigurer.java |  3 +++
 .../camel/main/DefaultConfigurationProperties.java | 24 ++++++++++++++++++++++
 .../main/MainSupervisingRouteControllerTest.java   |  4 +++-
 5 files changed, 36 insertions(+), 1 deletion(-)

diff --git 
a/core/camel-main/src/generated/java/org/apache/camel/main/MainConfigurationPropertiesConfigurer.java
 
b/core/camel-main/src/generated/java/org/apache/camel/main/MainConfigurationPropertiesConfigurer.java
index 07b19fb..df6f5dd 100644
--- 
a/core/camel-main/src/generated/java/org/apache/camel/main/MainConfigurationPropertiesConfigurer.java
+++ 
b/core/camel-main/src/generated/java/org/apache/camel/main/MainConfigurationPropertiesConfigurer.java
@@ -119,6 +119,8 @@ public class MainConfigurationPropertiesConfigurer extends 
org.apache.camel.supp
         case "RouteControllerIncludeRoutes": 
target.setRouteControllerIncludeRoutes(property(camelContext, 
java.lang.String.class, value)); return true;
         case "routecontrollerinitialdelay":
         case "RouteControllerInitialDelay": 
target.setRouteControllerInitialDelay(property(camelContext, long.class, 
value)); return true;
+        case "routecontrollerroutestartuplogginglevel":
+        case "RouteControllerRouteStartupLoggingLevel": 
target.setRouteControllerRouteStartupLoggingLevel(property(camelContext, 
org.apache.camel.LoggingLevel.class, value)); return true;
         case "routecontrollersuperviseenabled":
         case "RouteControllerSuperviseEnabled": 
target.setRouteControllerSuperviseEnabled(property(camelContext, boolean.class, 
value)); return true;
         case "routecontrollerthreadpoolsize":
@@ -236,6 +238,7 @@ public class MainConfigurationPropertiesConfigurer extends 
org.apache.camel.supp
         answer.put("RouteControllerExcludeRoutes", java.lang.String.class);
         answer.put("RouteControllerIncludeRoutes", java.lang.String.class);
         answer.put("RouteControllerInitialDelay", long.class);
+        answer.put("RouteControllerRouteStartupLoggingLevel", 
org.apache.camel.LoggingLevel.class);
         answer.put("RouteControllerSuperviseEnabled", boolean.class);
         answer.put("RouteControllerThreadPoolSize", int.class);
         answer.put("RouteFilterExcludePattern", java.lang.String.class);
@@ -373,6 +376,8 @@ public class MainConfigurationPropertiesConfigurer extends 
org.apache.camel.supp
         case "RouteControllerIncludeRoutes": return 
target.getRouteControllerIncludeRoutes();
         case "routecontrollerinitialdelay":
         case "RouteControllerInitialDelay": return 
target.getRouteControllerInitialDelay();
+        case "routecontrollerroutestartuplogginglevel":
+        case "RouteControllerRouteStartupLoggingLevel": return 
target.getRouteControllerRouteStartupLoggingLevel();
         case "routecontrollersuperviseenabled":
         case "RouteControllerSuperviseEnabled": return 
target.isRouteControllerSuperviseEnabled();
         case "routecontrollerthreadpoolsize":
diff --git 
a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
 
b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
index b162d2e..898821d 100644
--- 
a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
+++ 
b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
@@ -57,6 +57,7 @@
     { "name": "camel.main.routeControllerExcludeRoutes", "description": 
"Pattern for filtering routes to be included as supervised. The pattern is 
matching on route id, and endpoint uri for the route. Multiple patterns can be 
separated by comma. For example to include all kafka routes, you can say 
kafka:. And to include routes with specific route ids myRoute,myOtherRoute. The 
pattern supports wildcards and uses the matcher from 
org.apache.camel.support.PatternHelper#matchPattern.", "sour [...]
     { "name": "camel.main.routeControllerIncludeRoutes", "description": 
"Pattern for filtering routes to be excluded as supervised. The pattern is 
matching on route id, and endpoint uri for the route. Multiple patterns can be 
separated by comma. For example to exclude all JMS routes, you can say jms:. 
And to exclude routes with specific route ids 
mySpecialRoute,myOtherSpecialRoute. The pattern supports wildcards and uses the 
matcher from org.apache.camel.support.PatternHelper#matchPatter [...]
     { "name": "camel.main.routeControllerInitialDelay", "description": 
"Initial delay in milli seconds before the route controller starts, after 
CamelContext has been started.", "sourceType": 
"org.apache.camel.main.DefaultConfigurationProperties", "type": "integer", 
"javaType": "long" },
+    { "name": "camel.main.routeControllerRouteStartupLoggingLevel", 
"description": "Sets the logging level used for logging route startup activity. 
By default INFO level is used. You can use this to change the level for example 
to OFF if this kind of logging is not wanted.", "sourceType": 
"org.apache.camel.main.DefaultConfigurationProperties", "type": "object", 
"javaType": "org.apache.camel.LoggingLevel", "enum": [ "ERROR", "WARN", "INFO", 
"DEBUG", "TRACE", "OFF" ] },
     { "name": "camel.main.routeControllerSuperviseEnabled", "description": "To 
enable using supervising route controller which allows Camel to startup and 
then the controller takes care of starting the routes in a safe manner. This 
can be used when you want to startup Camel despite a route may otherwise fail 
fast during startup and cause Camel to fail to startup as well. By delegating 
the route startup to the supervising route controller then its manages the 
startup using a background th [...]
     { "name": "camel.main.routeControllerThreadPoolSize", "description": "The 
number of threads used by the route controller scheduled thread pool that are 
used for restarting routes. The pool uses 1 thread by default, but you can 
increase this to allow the controller to concurrently attempt to restart 
multiple routes in case more than one route has problems starting.", 
"sourceType": "org.apache.camel.main.DefaultConfigurationProperties", "type": 
"integer", "javaType": "int" },
     { "name": "camel.main.routeFilterExcludePattern", "description": "Used for 
filtering routes routes matching the given pattern, which follows the following 
rules: - Match by route id - Match by route input endpoint uri The matching is 
using exact match, by wildcard and regular expression as documented by 
PatternHelper#matchPattern(String,String) . For example to only include routes 
which starts with foo in their route id's, use: include=foo&#42; And to exclude 
routes which starts from [...]
diff --git 
a/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java
 
b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java
index bfa5855..12b0ccc 100644
--- 
a/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java
+++ 
b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java
@@ -209,6 +209,9 @@ public final class DefaultConfigurationConfigurer {
                 
src.setBackOffMultiplier(config.getRouteControllerBackOffMultiplier());
             }
         }
+        if (config.getRouteControllerRouteStartupLoggingLevel() != null) {
+            
camelContext.getRouteController().setRouteStartupLoggingLevel(config.getRouteControllerRouteStartupLoggingLevel());
+        }
     }
 
     /**
diff --git 
a/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationProperties.java
 
b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationProperties.java
index a8cd975..a8109af 100644
--- 
a/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationProperties.java
+++ 
b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationProperties.java
@@ -81,6 +81,7 @@ public abstract class DefaultConfigurationProperties<T> {
     private String xmlRoutes = "classpath:camel/*.xml";
     private String xmlRests = "classpath:camel-rest/*.xml";
     private boolean lightweight;
+    private LoggingLevel routeControllerRouteStartupLoggingLevel;
     private boolean routeControllerSuperviseEnabled;
     private String routeControllerIncludeRoutes;
     private String routeControllerExcludeRoutes;
@@ -900,6 +901,19 @@ public abstract class DefaultConfigurationProperties<T> {
         this.lightweight = lightweight;
     }
 
+    public LoggingLevel getRouteControllerRouteStartupLoggingLevel() {
+        return routeControllerRouteStartupLoggingLevel;
+    }
+
+    /**
+     * Sets the logging level used for logging route startup activity.
+     * By default INFO level is used. You can use this to change the level for 
example to OFF if
+     * this kind of logging is not wanted.
+     */
+    public void setRouteControllerRouteStartupLoggingLevel(LoggingLevel 
routeControllerRouteStartupLoggingLevel) {
+        this.routeControllerRouteStartupLoggingLevel = 
routeControllerRouteStartupLoggingLevel;
+    }
+
     public boolean isRouteControllerSuperviseEnabled() {
         return routeControllerSuperviseEnabled;
     }
@@ -1690,6 +1704,16 @@ public abstract class DefaultConfigurationProperties<T> {
     }
 
     /**
+     * Sets the logging level used for logging route startup activity.
+     * By default INFO level is used. You can use this to change the level for 
example to OFF if
+     * this kind of logging is not wanted.
+     */
+    public T withRouteStartupLoggingLevel(LoggingLevel 
routeStartupLoggingLevel) {
+        this.routeControllerRouteStartupLoggingLevel = 
routeStartupLoggingLevel;
+        return (T) this;
+    }
+
+    /**
      * To enable using supervising route controller which allows Camel to 
startup
      * and then the controller takes care of starting the routes in a safe 
manner.
      *
diff --git 
a/core/camel-main/src/test/java/org/apache/camel/main/MainSupervisingRouteControllerTest.java
 
b/core/camel-main/src/test/java/org/apache/camel/main/MainSupervisingRouteControllerTest.java
index 76124b6..53a1a71 100644
--- 
a/core/camel-main/src/test/java/org/apache/camel/main/MainSupervisingRouteControllerTest.java
+++ 
b/core/camel-main/src/test/java/org/apache/camel/main/MainSupervisingRouteControllerTest.java
@@ -21,6 +21,7 @@ import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.Consumer;
 import org.apache.camel.Endpoint;
+import org.apache.camel.LoggingLevel;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
@@ -38,7 +39,8 @@ public class MainSupervisingRouteControllerTest extends 
Assert {
         // lets make a simple route
         Main main = new Main();
         main.configure().addRoutesBuilder(new MyRoute());
-        main.configure().withRouteControllerSuperviseEnabled(true)
+        main.configure().withRouteStartupLoggingLevel(LoggingLevel.OFF)
+                        .withRouteControllerSuperviseEnabled(true)
                         .withRouteControllerBackOffDelay(25)
                         .withRouteControllerBackOffMaxAttempts(3)
                         .withRouteControllerInitialDelay(100)

Reply via email to