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 c4ba9919767bca855bfd9304fdbf73996afff895
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu Mar 18 09:25:30 2021 +0100

    Make camel-bundle-plugin less noisy by not logging harmless WARN
---
 .../apache/felix/bundleplugin/ManifestPlugin.java  |   4 +
 .../org/apache/felix/bundleplugin/PatchedLog.java  | 116 +++++++++++++++++++++
 2 files changed, 120 insertions(+)

diff --git 
a/init/camel-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
 
b/init/camel-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
index 303ba1e..8944cbb 100644
--- 
a/init/camel-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
+++ 
b/init/camel-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
@@ -103,6 +103,10 @@ public class ManifestPlugin extends BundlePlugin {
             return;
         }
 
+        // avoid noisy logging
+        PatchedLog plog = new PatchedLog(getLog());
+        setLog(plog);
+
         Analyzer analyzer;
         try {
             analyzer = getAnalyzer(project, instructions, classpath);
diff --git 
a/init/camel-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/PatchedLog.java
 
b/init/camel-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/PatchedLog.java
new file mode 100644
index 0000000..86895b8
--- /dev/null
+++ 
b/init/camel-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/PatchedLog.java
@@ -0,0 +1,116 @@
+/*
+ * 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.felix.bundleplugin;
+
+import org.apache.maven.plugin.logging.Log;
+
+/**
+ * Patched logger that is not noisy.
+ */
+public class PatchedLog implements Log {
+
+    private final Log delegate;
+
+    public PatchedLog(Log delegate) {
+        this.delegate = delegate;
+    }
+
+    @Override
+    public boolean isDebugEnabled() {
+        return delegate.isDebugEnabled();
+    }
+
+    @Override
+    public void debug(CharSequence charSequence) {
+        delegate.debug(charSequence);
+    }
+
+    @Override
+    public void debug(CharSequence charSequence, Throwable throwable) {
+        delegate.debug(charSequence, throwable);
+    }
+
+    @Override
+    public void debug(Throwable throwable) {
+        delegate.debug(throwable);
+    }
+
+    @Override
+    public boolean isInfoEnabled() {
+        return delegate.isInfoEnabled();
+    }
+
+    @Override
+    public void info(CharSequence charSequence) {
+        delegate.info(charSequence);
+    }
+
+    @Override
+    public void info(CharSequence charSequence, Throwable throwable) {
+        delegate.info(charSequence, throwable);
+    }
+
+    @Override
+    public void info(Throwable throwable) {
+        delegate.info(throwable);
+    }
+
+    @Override
+    public boolean isWarnEnabled() {
+        return delegate.isWarnEnabled();
+    }
+
+    @Override
+    public void warn(CharSequence charSequence) {
+        // skip some unwanted WARN logging
+        String s = charSequence.toString();
+        if (s.startsWith("Include-Resource: overriding")) {
+            return;
+        }
+        delegate.warn(charSequence);
+    }
+
+    @Override
+    public void warn(CharSequence charSequence, Throwable throwable) {
+        delegate.warn(charSequence, throwable);
+    }
+
+    @Override
+    public void warn(Throwable throwable) {
+        delegate.warn(throwable);
+    }
+
+    @Override
+    public boolean isErrorEnabled() {
+        return delegate.isErrorEnabled();
+    }
+
+    @Override
+    public void error(CharSequence charSequence) {
+        delegate.error(charSequence);
+    }
+
+    @Override
+    public void error(CharSequence charSequence, Throwable throwable) {
+        delegate.error(charSequence, throwable);
+    }
+
+    @Override
+    public void error(Throwable throwable) {
+        delegate.error(throwable);
+    }
+}

Reply via email to