You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2022/06/23 08:04:57 UTC

[camel-k-runtime] branch main updated: Add new module for structural Maven logging

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

acosentino pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k-runtime.git


The following commit(s) were added to refs/heads/main by this push:
     new cd873211 Add new module for structural Maven logging
cd873211 is described below

commit cd8732111509df3f1373d6f9aa1166f31927d158
Author: Christoph Deppisch <cd...@redhat.com>
AuthorDate: Wed Jun 15 14:07:11 2022 +0200

    Add new module for structural Maven logging
    
    - Module collects logging artifacts that enable structural Maven output
    - Camel K Docker image will use these artifacts to add structural Maven logging to IntegrationKit build output
---
 .gitignore                                         |   1 +
 pom.xml                                            |   2 +
 support/camel-k-maven-logging/pom.xml              | 147 +++++++++++++++++++++
 .../src/main/assembly/overlay.xml                  |  47 +++++++
 .../src/main/resources/logback.xml                 |  67 ++++++++++
 support/pom.xml                                    |   1 +
 6 files changed, 265 insertions(+)

diff --git a/.gitignore b/.gitignore
index 58452612..fe1a519a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,4 @@ target
 .factorypath
 .classpath
 
+.DS_Store
diff --git a/pom.xml b/pom.xml
index 9f03e52d..55f05ece 100644
--- a/pom.xml
+++ b/pom.xml
@@ -59,6 +59,8 @@
         <!-- plugins -->
         <gmavenplus-plugin-version>1.13.1</gmavenplus-plugin-version>
         <maven-compiler-plugin-version>3.10.1</maven-compiler-plugin-version>
+        <maven-assembly-plugin-version>3.3.0</maven-assembly-plugin-version>
+        <maven-dependency-plugin-version>3.3.0</maven-dependency-plugin-version>
         <maven-surefire-plugin-version>3.0.0-M7</maven-surefire-plugin-version>
         <maven-remote-resources-plugin-version>1.7.0</maven-remote-resources-plugin-version>
         <maven-failsafe-plugin-version>3.0.0-M7</maven-failsafe-plugin-version>
diff --git a/support/camel-k-maven-logging/pom.xml b/support/camel-k-maven-logging/pom.xml
new file mode 100644
index 00000000..4cb0b622
--- /dev/null
+++ b/support/camel-k-maven-logging/pom.xml
@@ -0,0 +1,147 @@
+<!--
+
+    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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <groupId>org.apache.camel.k</groupId>
+        <artifactId>camel-k-support</artifactId>
+        <version>1.14.0-SNAPSHOT</version>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>camel-k-maven-logging</artifactId>
+    <description>Set of dependencies used for structural logging of Maven output</description>
+    <packaging>pom</packaging>
+
+    <properties>
+      <!-- Maven structural logging -->
+      <logback-version>1.2.3</logback-version>
+      <logstash-logback-version>4.11</logstash-logback-version>
+      <jackson-version>2.9.10</jackson-version>
+      <jackson-databind-version>2.9.10.8</jackson-databind-version>
+    </properties>
+
+    <dependencyManagement>
+        <dependencies>
+            <!-- structural Maven logging -->
+            <dependency>
+                <groupId>ch.qos.logback</groupId>
+                <artifactId>logback-core</artifactId>
+                <version>${logback-version}</version>
+            </dependency>
+            <dependency>
+                <groupId>ch.qos.logback</groupId>
+                <artifactId>logback-classic</artifactId>
+                <version>${logback-version}</version>
+            </dependency>
+            <dependency>
+                <groupId>net.logstash.logback</groupId>
+                <artifactId>logstash-logback-encoder</artifactId>
+                <version>${logstash-logback-version}</version>
+            </dependency>
+            <dependency>
+                <groupId>com.fasterxml.jackson.core</groupId>
+                <artifactId>jackson-annotations</artifactId>
+                <version>${jackson-version}</version>
+            </dependency>
+            <dependency>
+                <groupId>com.fasterxml.jackson.core</groupId>
+                <artifactId>jackson-core</artifactId>
+                <version>${jackson-version}</version>
+            </dependency>
+            <dependency>
+                <groupId>com.fasterxml.jackson.core</groupId>
+                <artifactId>jackson-databind</artifactId>
+                <version>${jackson-databind-version}</version>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <build>
+        <defaultGoal>generate-resources</defaultGoal>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <version>${maven-dependency-plugin-version}</version>
+                <executions>
+                    <execution>
+                        <id>default-cli</id>
+                        <phase>generate-resources</phase>
+                        <goals>
+                            <goal>copy-dependencies</goal>
+                        </goals>
+                        <configuration>
+                            <excludeTransitive>true</excludeTransitive>
+                            <outputDirectory>${project.build.directory}/maven-overlay</outputDirectory>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <version>${maven-assembly-plugin-version}</version>
+                <executions>
+                    <execution>
+                        <id>dist-overlay</id>
+                        <phase>generate-resources</phase>
+                        <goals>
+                            <goal>single</goal>
+                        </goals>
+                        <configuration>
+                            <appendAssemblyId>false</appendAssemblyId>
+                            <descriptors>
+                                <descriptor>src/main/assembly/overlay.xml</descriptor>
+                            </descriptors>
+                            <attach>true</attach>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <!-- structural logging -->
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-classic</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>net.logstash.logback</groupId>
+            <artifactId>logstash-logback-encoder</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-annotations</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/support/camel-k-maven-logging/src/main/assembly/overlay.xml b/support/camel-k-maven-logging/src/main/assembly/overlay.xml
new file mode 100644
index 00000000..f82244c6
--- /dev/null
+++ b/support/camel-k-maven-logging/src/main/assembly/overlay.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
+  <id>overlay</id>
+
+  <formats>
+    <format>zip</format>
+  </formats>
+
+  <includeBaseDirectory>false</includeBaseDirectory>
+
+  <fileSets>
+    <fileSet>
+      <directory>${project.build.directory}/maven-overlay</directory>
+      <outputDirectory/>
+      <includes>
+        <include>*.jar</include>
+      </includes>
+    </fileSet>
+  </fileSets>
+
+  <files>
+    <file>
+      <source>${project.basedir}/src/main/resources/logback.xml</source>
+      <outputDirectory/>
+    </file>
+  </files>
+</assembly>
diff --git a/support/camel-k-maven-logging/src/main/resources/logback.xml b/support/camel-k-maven-logging/src/main/resources/logback.xml
new file mode 100644
index 00000000..f752b501
--- /dev/null
+++ b/support/camel-k-maven-logging/src/main/resources/logback.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<configuration>
+    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+        <!--
+        This configuration tries to output the Maven build log in a way that is as close as possible the native k8s
+        log output format.
+        -->
+        <encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
+            <providers>
+                <logLevel>
+                    <fieldName>level</fieldName>
+                </logLevel>
+                <timestamp>
+                    <fieldName>ts</fieldName>
+                    <timeZone>UTC</timeZone>
+                </timestamp>
+                <loggerName>
+                    <fieldName>logger</fieldName>
+                </loggerName>
+                <message>
+                    <fieldName>msg</fieldName>
+                </message>
+                <callerData>
+                    <classFieldName>class</classFieldName>
+                </callerData>
+                <threadName>
+                    <fieldName>thread</fieldName>
+                </threadName>
+                <mdc/>
+                <arguments>
+                    <includeNonStructuredArguments>false</includeNonStructuredArguments>
+                </arguments>
+                <logstashMarkers/>
+                <stackTrace>
+                    <fieldName>stack</fieldName>
+                    <throwableConverter class="net.logstash.logback.stacktrace.ShortenedThrowableConverter">
+                        <maxLength>4096</maxLength>
+                        <rootCauseFirst>false</rootCauseFirst>
+                    </throwableConverter>
+                </stackTrace>
+            </providers>
+        </encoder>
+    </appender>
+
+    <root level="INFO">
+        <appender-ref ref="CONSOLE"/>
+    </root>
+
+</configuration>
diff --git a/support/pom.xml b/support/pom.xml
index 96902196..9021315e 100644
--- a/support/pom.xml
+++ b/support/pom.xml
@@ -37,6 +37,7 @@
         <module>camel-k-itests-support</module>
         <module>camel-k-catalog</module>
         <module>camel-k-runtime-bom</module>
+        <module>camel-k-maven-logging</module>
     </modules>
 
 </project>