Integrate logging-markers 42/89742/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 13 May 2020 21:32:58 +0000 (23:32 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 14 May 2020 08:08:05 +0000 (10:08 +0200)
Previous patch did not completely integrate our logging markers,
this patch finishes the job by adding them to the baseline karaf-empty
distribution.

Furthermore add some documentation and move Markers into a separate
package, forming a proper JPMS module.

JIRA: ODLPARENT-231
Change-Id: I902d7b87c67fa84cc1f84bb06031952951f98a93
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 471914379dfe5abdc82654f2d37167135ca5c5bf)

karaf/opendaylight-karaf-resources/pom.xml
logging-markers/pom.xml
logging-markers/src/main/java/org/opendaylight/odlparent/Markers.java [deleted file]
logging-markers/src/main/java/org/opendaylight/odlparent/logging/markers/Markers.java [new file with mode: 0644]
untested-single-feature-parent/pom.xml

index b933a12612c83396188bcd8c5b3e2f19a951d15a..ab60e8a5d84f7aeb87de4b3ae945ee5b12c0f746 100644 (file)
       <artifactId>bcprov-framework-ext</artifactId>
       <scope>runtime</scope>
     </dependency>
+
+    <!-- SLF4J logging markers -->
+    <dependency>
+      <groupId>org.opendaylight.odlparent</groupId>
+      <artifactId>logging-markers</artifactId>
+      <scope>runtime</scope>
+    </dependency>
   </dependencies>
 
   <build>
@@ -135,6 +142,7 @@ mvn\:org.osgi/org.osgi.service.event/1.3.1 = 7
 mvn\:org.apache.felix/org.apache.felix.metatype/1.2.2 = 8
 mvn\:org.opendaylight.odlparent/bcprov-framework-ext/${project.version} = 14
 mvn\:org.opendaylight.odlparent/bcpkix-framework-ext/${project.version} = 14
+mvn\:org.opendaylight.odlparent/logging-markers/${project.version} = 14
 mvn\:org.apache.aries.blueprint/org.apache.aries.blueprint.core.compatibility/1.0.0 = 14
                 </echo>
                 <copy file="${project.build.directory}/assembly/etc/startup.properties"
index 87ec6a6322e20623098c7f79d5e330fa85cfddad..1b4c8d2e61933447b924bfb0ecf4444494cd3a8f 100644 (file)
@@ -1,6 +1,13 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<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">
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+ Copyright (c) 2020 PANTHEON.tech, s.r.o. and others.  All rights reserved.
 
+ This program and the accompanying materials are made available under the
+ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+<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">
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>logging-markers</artifactId>
     <packaging>bundle</packaging>
     <name>OpenDaylight :: Logging Markers</name>
+    <description>OpenDaylight-specific SLF4J Markers</description>
 
-    <dependencies>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>ch.qos.logback</groupId>
-            <artifactId>logback-classic</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>ch.qos.logback</groupId>
-            <artifactId>logback-core</artifactId>
-        </dependency>
-    </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Automatic-Module-Name>org.opendaylight.odlparent.logging.markers</Automatic-Module-Name>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
 </project>
diff --git a/logging-markers/src/main/java/org/opendaylight/odlparent/Markers.java b/logging-markers/src/main/java/org/opendaylight/odlparent/Markers.java
deleted file mode 100644 (file)
index 7ae3416..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.odlparent;
-
-import org.slf4j.Marker;
-import org.slf4j.MarkerFactory;
-
-public final class Markers {
-
-    private Markers() {
-    }
-
-    public static Marker confidential() {
-        return Confidential.MARKER;
-    }
-
-    private static final class Confidential {
-        private static String CONFIDENTIAL_TAG = "CONFIDENTIAL";
-        static final Marker MARKER = MarkerFactory.getMarker(CONFIDENTIAL_TAG);
-    }
-}
diff --git a/logging-markers/src/main/java/org/opendaylight/odlparent/logging/markers/Markers.java b/logging-markers/src/main/java/org/opendaylight/odlparent/logging/markers/Markers.java
new file mode 100644 (file)
index 0000000..f211b06
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.odlparent.logging.markers;
+
+import org.slf4j.Marker;
+import org.slf4j.MarkerFactory;
+
+/**
+ * Common markers for SLF4J. See individual methods for available markers and their use.
+ */
+public final class Markers {
+    private Markers() {
+        // Hidden on purpose
+    }
+
+    /**
+     * Return the SLF4J marker for reporting messages which may contain sensitive information, such as credentials
+     * used with an external system. This marker should be used by code components when dumping protocol data, such
+     * as NETCONF messages, which may contain user passwords and similar. Logging provider should be configured to
+     * redirect messages marked with this marker to a separate location which enjoys a higher level of confidentiality
+     * and protection than other messages.
+     *
+     * @return The confidential marker.
+     */
+    public static Marker confidential() {
+        return Confidential.MARKER;
+    }
+
+    // https://en.wikipedia.org/wiki/Initialization-on-demand_holder_idiom
+    private static final class Confidential {
+        static final Marker MARKER = MarkerFactory.getMarker("CONFIDENTIAL");
+    }
+}
index 016820e821459f1de766e8acf63b336018905889..3641e51065785d3e27d08f0625ca60f1ee08502b 100644 (file)
@@ -88,6 +88,9 @@
                         <!-- javax.annotation -->
                         <excludedArtifactId>activation</excludedArtifactId>
                         <excludedArtifactId>jakarta.activation-api</excludedArtifactId>
+
+                        <!-- Our slf4j logging markers -->
+                        <excludedArtifactId>logging-markers</excludedArtifactId>
                     </excludedArtifactIds>
                 </configuration>
             </plugin>