You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2022/05/10 16:03:30 UTC

[activemq-artemis] 11/19: WIP: some notes

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

clebertsuconic pushed a commit to branch new-logging
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git

commit a879ed08fb8ff197f0a07684b58171507de85098
Author: Robbie Gemmell <ro...@apache.org>
AuthorDate: Wed May 4 13:13:34 2022 +0100

    WIP: some notes
---
 artemis-commons/pom.xml                                    |  1 +
 artemis-core-client/pom.xml                                |  1 +
 artemis-log-processor/pom.xml                              |  3 +--
 .../apache/activemq/artemis/logprocessor/LogProcessor.java |  9 ++++++---
 .../artemis/logprocessor/annotation/ArtemisBundle.java     |  2 +-
 .../artemis/logprocessor/annotation/LogMessage.java        |  4 ++--
 pom.xml                                                    |  9 ++++++---
 tests/integration-tests/pom.xml                            | 14 +++++---------
 8 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/artemis-commons/pom.xml b/artemis-commons/pom.xml
index c8beb16500..c77f38add7 100644
--- a/artemis-commons/pom.xml
+++ b/artemis-commons/pom.xml
@@ -56,6 +56,7 @@
          <groupId>org.apache.activemq</groupId>
          <artifactId>artemis-log-processor</artifactId>
          <version>${project.version}</version>
+          <!-- <scope>provided</scope> so that it isnt picked up and run by users: it is currently being spread everywhere by artemis-commons -->
       </dependency>
       <dependency>
          <groupId>org.slf4j</groupId>
diff --git a/artemis-core-client/pom.xml b/artemis-core-client/pom.xml
index 319e1a037b..6f74ef8386 100644
--- a/artemis-core-client/pom.xml
+++ b/artemis-core-client/pom.xml
@@ -37,6 +37,7 @@
          <groupId>org.apache.activemq</groupId>
          <artifactId>artemis-log-processor</artifactId>
          <version>${project.version}</version>
+         <!-- <scope>provided</scope> so that it isnt picked up and run by users: it is currently being spread everywhere by artemis-commons -->
       </dependency>
       <dependency>
          <groupId>org.slf4j</groupId>
diff --git a/artemis-log-processor/pom.xml b/artemis-log-processor/pom.xml
index aa22db6191..7976f143c6 100644
--- a/artemis-log-processor/pom.xml
+++ b/artemis-log-processor/pom.xml
@@ -48,8 +48,7 @@
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <scope>test</scope>
-         <!-- License: CPL 1.0 -->
-         <!-- There are newer versions of the JUnit but they break our tests -->
+         <!-- License: EPL 1.0 -->
       </dependency>
    </dependencies>
 
diff --git a/artemis-log-processor/src/main/java/org/apache/activemq/artemis/logprocessor/LogProcessor.java b/artemis-log-processor/src/main/java/org/apache/activemq/artemis/logprocessor/LogProcessor.java
index 5195c0759a..e4e18ca54d 100644
--- a/artemis-log-processor/src/main/java/org/apache/activemq/artemis/logprocessor/LogProcessor.java
+++ b/artemis-log-processor/src/main/java/org/apache/activemq/artemis/logprocessor/LogProcessor.java
@@ -20,6 +20,8 @@ package org.apache.activemq.artemis.logprocessor;
 import javax.annotation.processing.AbstractProcessor;
 import javax.annotation.processing.RoundEnvironment;
 import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
 import javax.lang.model.element.Element;
 import javax.lang.model.element.ElementKind;
 import javax.lang.model.element.ExecutableElement;
@@ -37,8 +39,9 @@ import org.apache.activemq.artemis.logprocessor.annotation.LogMessage;
 import org.apache.activemq.artemis.logprocessor.annotation.Message;
 
 @SupportedAnnotationTypes({"org.apache.activemq.artemis.logprocessor.annotation.ArtemisBundle"})
+@SupportedSourceVersion(SourceVersion.RELEASE_11)
 public class LogProcessor extends AbstractProcessor {
-
+   // Would be good if this was in its own module seperate from the annotations so that it isnt picked up by and thus run (to no effect) by users, which it currently would be but ideally would not be.
 
    @Override
    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
@@ -114,7 +117,7 @@ public class LogProcessor extends AbstractProcessor {
                      GetLogger getLogger = el.getAnnotation(GetLogger.class);
 
 
-                     if (messageAnnotation != null && logAnnotation != null && getLogger != null) {
+                     if (messageAnnotation != null && logAnnotation != null && getLogger != null) { //This requires all 3 are set to fail, it wont pick up other combinations as the message suggests might be wanted.
                         processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "Cannot use combied annotations " + el);
                         return false;
                      }
@@ -149,7 +152,7 @@ public class LogProcessor extends AbstractProcessor {
                                 Message messageAnnotation,
                                 HashMap<Integer, String> processedMessages) {
 
-      String previousMessage = processedMessages.get(messageAnnotation.id());
+      String previousMessage = processedMessages.get(messageAnnotation.id()); // Could move inside the if?
 
       if (processedMessages.containsKey(messageAnnotation.id())) {
          throw new IllegalStateException("message " + messageAnnotation.id() + " with definition = " + messageAnnotation.value() + " was previously defined as " + previousMessage);
diff --git a/artemis-log-processor/src/main/java/org/apache/activemq/artemis/logprocessor/annotation/ArtemisBundle.java b/artemis-log-processor/src/main/java/org/apache/activemq/artemis/logprocessor/annotation/ArtemisBundle.java
index 5d7aaf8d55..188382973e 100644
--- a/artemis-log-processor/src/main/java/org/apache/activemq/artemis/logprocessor/annotation/ArtemisBundle.java
+++ b/artemis-log-processor/src/main/java/org/apache/activemq/artemis/logprocessor/annotation/ArtemisBundle.java
@@ -24,7 +24,7 @@ import java.lang.annotation.Target;
 
 @Target(ElementType.TYPE)
 @Retention(RetentionPolicy.SOURCE)
-public @interface ArtemisBundle {
+public @interface ArtemisBundle { // Maybe ArtemisLogBundle or even just LogBundle?
 
    String projectCode();
 }
diff --git a/artemis-log-processor/src/main/java/org/apache/activemq/artemis/logprocessor/annotation/LogMessage.java b/artemis-log-processor/src/main/java/org/apache/activemq/artemis/logprocessor/annotation/LogMessage.java
index e1f08fe2ac..9496cd4a58 100644
--- a/artemis-log-processor/src/main/java/org/apache/activemq/artemis/logprocessor/annotation/LogMessage.java
+++ b/artemis-log-processor/src/main/java/org/apache/activemq/artemis/logprocessor/annotation/LogMessage.java
@@ -30,11 +30,11 @@ public @interface LogMessage {
 
    String value();
 
-   Level level() default Level.WARN;
+   Level level() default Level.WARN; // Having a default for this seems less clear than just having the level specified all the time. (If null gets passed the requirement to specify a value, cant the processor detect that was given and fail?
 
    enum Level {
       FATAL, ERROR, WARN, INFO,
-        @Deprecated DEBUG, @Deprecated TRACE;
+        @Deprecated DEBUG, @Deprecated TRACE; // Question: is the idea of this that debug stuff shouldnt have codes and so shouldnt use the annotations? Is that currently true?
 
       private Level() {
       }
diff --git a/pom.xml b/pom.xml
index 6087ba9578..b1e84bea28 100644
--- a/pom.xml
+++ b/pom.xml
@@ -118,7 +118,6 @@
       <hdrhistogram.version>2.1.12</hdrhistogram.version>
       <curator.version>5.2.0</curator.version>
       <zookeeper.version>3.6.3</zookeeper.version>
-      <slf4j-version>1.7.36</slf4j-version>
 
       <!-- tracing -->
       <opentelemetry.version>1.10.0</opentelemetry.version>
@@ -688,13 +687,17 @@
          <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
-           <version>${slf4j-version}</version>
+           <version>${slf4j.version}</version>
            <!-- License: MIT -->
          </dependency>
+
+         <!-- TODO: Remove this, and all uses. It is the Log4J 1.2 binding and thus is
+	                ancient. It doenst actually exist anymore either, being redirected
+                    to slf4j-reload4j with a warning emitted in the build by maven -->
          <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-log4j12</artifactId>
-            <version>${slf4j-version}</version>
+            <version>${slf4j.version}</version>   <!-- Change note: slf4j.version already present -->
          </dependency>
 
          <!--needed for the rest support-->
diff --git a/tests/integration-tests/pom.xml b/tests/integration-tests/pom.xml
index a5ceaa2a76..053e4fc04b 100644
--- a/tests/integration-tests/pom.xml
+++ b/tests/integration-tests/pom.xml
@@ -229,15 +229,6 @@
          <groupId>jakarta.management.j2ee</groupId>
          <artifactId>jakarta.management.j2ee-api</artifactId>
       </dependency>
-      <!-- logging -->
-      <dependency>
-         <groupId>org.slf4j</groupId>
-         <artifactId>slf4j-api</artifactId>
-      </dependency>
-      <dependency>
-         <groupId>org.slf4j</groupId>
-         <artifactId>slf4j-log4j12</artifactId>
-      </dependency>
       <dependency>
          <groupId>io.netty</groupId>
          <artifactId>netty-buffer</artifactId>
@@ -271,10 +262,15 @@
          <groupId>org.apache.qpid</groupId>
          <artifactId>proton-j</artifactId>
       </dependency>
+      <!-- logging -->
       <dependency>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-api</artifactId>
       </dependency>
+      <dependency> <!-- TODO: replace with e.g Log4J 2 -->
+         <groupId>org.slf4j</groupId>
+         <artifactId>slf4j-log4j12</artifactId>
+      </dependency>
       <dependency>
          <groupId>org.apache.activemq</groupId>
          <artifactId>artemis-web</artifactId>