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/11 13:50:51 UTC
[activemq-artemis] 06/23: progress
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 2115b4fddf23325e666fdadf4e3b89e4b0344113
Author: Clebert Suconic <cl...@apache.org>
AuthorDate: Tue May 3 10:13:22 2022 -0400
progress
---
.../logprocessor/annotation/LogMessage.java | 10 ++
.../activemq/artemis/logs/ActiveMQUtilBundle.java | 23 ++--
.../activemq/artemis/logs/ActiveMQUtilLogger.java | 18 +--
.../logs/JBossLoggingApacheLoggerBridge.java | 135 ---------------------
.../logprocessor/annotation/LogMessage.java | 7 ++
.../core/server/ActiveMQServerNewLogger.java | 5 +-
6 files changed, 33 insertions(+), 165 deletions(-)
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/logprocessor/annotation/LogMessage.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/logprocessor/annotation/LogMessage.java
index bcaee8a093..bb66a40b10 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/logprocessor/annotation/LogMessage.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/logprocessor/annotation/LogMessage.java
@@ -30,4 +30,14 @@ public @interface LogMessage {
String value();
+ Level level() default Level.WARN;
+
+ enum Level {
+ FATAL, ERROR, WARN, INFO, DEBUG, TRACE;
+
+ private Level() {
+ }
+ }
+
+
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/ActiveMQUtilBundle.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/ActiveMQUtilBundle.java
index c32bc67c8e..705e9e3213 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/ActiveMQUtilBundle.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/ActiveMQUtilBundle.java
@@ -17,10 +17,9 @@
package org.apache.activemq.artemis.logs;
import org.apache.activemq.artemis.api.core.ActiveMQIllegalStateException;
-import org.jboss.logging.Messages;
-import org.jboss.logging.annotations.Cause;
-import org.jboss.logging.annotations.Message;
-import org.jboss.logging.annotations.MessageBundle;
+import org.apache.activemq.artemis.logprocessor.CodeFactory;
+import org.apache.activemq.artemis.logprocessor.annotation.ArtemisBundle;
+import org.apache.activemq.artemis.logprocessor.annotation.Message;
/**
* Logger Code 20
@@ -29,23 +28,23 @@ import org.jboss.logging.annotations.MessageBundle;
*
* so 209000 to 209999
*/
-@MessageBundle(projectCode = "AMQ")
+@ArtemisBundle(projectCode = "AMQ")
public interface ActiveMQUtilBundle {
- ActiveMQUtilBundle BUNDLE = Messages.getBundle(ActiveMQUtilBundle.class);
+ ActiveMQUtilBundle BUNDLE = CodeFactory.getBundle(ActiveMQUtilBundle.class);
- @Message(id = 209000, value = "invalid property: {0}", format = Message.Format.MESSAGE_FORMAT)
+ @Message(id = 209000, value = "invalid property: {0}")
ActiveMQIllegalStateException invalidProperty(String part);
- @Message(id = 209001, value = "Invalid type: {0}", format = Message.Format.MESSAGE_FORMAT)
+ @Message(id = 209001, value = "Invalid type: {0}")
IllegalStateException invalidType(Byte type);
- @Message(id = 209002, value = "the specified string is too long ({0})", format = Message.Format.MESSAGE_FORMAT)
+ @Message(id = 209002, value = "the specified string is too long ({0})")
IllegalStateException stringTooLong(Integer length);
- @Message(id = 209003, value = "Error instantiating codec {0}", format = Message.Format.MESSAGE_FORMAT)
- IllegalArgumentException errorCreatingCodec(@Cause Exception e, String codecClassName);
+ @Message(id = 209003, value = "Error instantiating codec {0}")
+ IllegalArgumentException errorCreatingCodec(Exception e, String codecClassName);
- @Message(id = 209004, value = "Failed to parse long value from {0}", format = Message.Format.MESSAGE_FORMAT)
+ @Message(id = 209004, value = "Failed to parse long value from {0}")
IllegalArgumentException failedToParseLong(String value);
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/ActiveMQUtilLogger.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/ActiveMQUtilLogger.java
index 834fbc1c30..a0883cd386 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/ActiveMQUtilLogger.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/ActiveMQUtilLogger.java
@@ -19,32 +19,16 @@ package org.apache.activemq.artemis.logs;
import org.apache.activemq.artemis.logprocessor.CodeFactory;
import org.apache.activemq.artemis.logprocessor.annotation.ArtemisBundle;
import org.apache.activemq.artemis.logprocessor.annotation.LogMessage;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Logger Code 20
- *
- * each message id must be 6 digits long starting with 20, the 3rd digit donates the level so
- *
- * INF0 1
- * WARN 2
- * DEBUG 3
- * ERROR 4
- * TRACE 5
- * FATAL 6
- *
- * so an INFO message would be 201000 to 201999
*/
@ArtemisBundle(projectCode = "AMQ")
public interface ActiveMQUtilLogger {
- /**
- * The default logger.
- */
ActiveMQUtilLogger LOGGER = CodeFactory.getMessageLogger(ActiveMQUtilLogger.class);
- @LogMessage(id = 201000, value = "Network is healthy, starting service {0}")
+ @LogMessage(id = 201000, value = "Network is healthy, starting service {0}", level = LogMessage.Level.INFO)
void startingService(String component);
@LogMessage(id = 201001, value = "Network is unhealthy, stopping service {0}")
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/JBossLoggingApacheLoggerBridge.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/JBossLoggingApacheLoggerBridge.java
deleted file mode 100644
index f53f0a613f..0000000000
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/JBossLoggingApacheLoggerBridge.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * 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.activemq.artemis.logs;
-
-import org.apache.commons.logging.Log;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * There is an issue on the Testsuite, as it's not possible
- * to bring JBossLogging on the booting classLoader.
- * As a result classes like BeanUtils will be using apache logging,
- * which will not have the bootstrapping necessary.
- *
- * As a result BeanUtils is keeping showing log.debug into the test output and test console.
- *
- * This class will give an opportunity to the CI and our applications to use proper logging even on the testsuite.
- * */
-public class JBossLoggingApacheLoggerBridge implements Log {
-
- final Logger bridgeLog;
-
- public JBossLoggingApacheLoggerBridge(Class clazz) {
- bridgeLog = LoggerFactory.getLogger(clazz);
- }
-
- public JBossLoggingApacheLoggerBridge(String name) {
- bridgeLog = LoggerFactory.getLogger(name);
- }
-
- @Override
- public void debug(Object message) {
- bridgeLog.debug(message);
- }
-
- @Override
- public void debug(Object message, Throwable t) {
- bridgeLog.debug(message, t);
- }
-
- @Override
- public void error(Object message) {
- bridgeLog.error(message);
- }
-
- @Override
- public void error(Object message, Throwable t) {
- bridgeLog.error(message, t);
- }
-
- @Override
- public void fatal(Object message) {
- bridgeLog.fatal(message);
- }
-
- @Override
- public void fatal(Object message, Throwable t) {
- bridgeLog.fatal(message, t);
- }
-
- @Override
- public void info(Object message) {
- bridgeLog.info(message);
- }
-
- @Override
- public void info(Object message, Throwable t) {
- bridgeLog.info(message, t);
- }
-
- @Override
- public boolean isDebugEnabled() {
- return bridgeLog.isDebugEnabled();
- }
-
- @Override
- public boolean isErrorEnabled() {
- return bridgeLog.isEnabled(Logger.Level.ERROR);
- }
-
- @Override
- public boolean isFatalEnabled() {
- return bridgeLog.isEnabled(Logger.Level.FATAL);
- }
-
- @Override
- public boolean isInfoEnabled() {
- return bridgeLog.isInfoEnabled();
- }
-
- @Override
- public boolean isTraceEnabled() {
- return bridgeLog.isTraceEnabled();
- }
-
- @Override
- public boolean isWarnEnabled() {
- return bridgeLog.isEnabled(Logger.Level.WARN);
- }
-
- @Override
- public void trace(Object message) {
- bridgeLog.trace(message);
- }
-
- @Override
- public void trace(Object message, Throwable t) {
- bridgeLog.trace(message, t);
- }
-
- @Override
- public void warn(Object message) {
- bridgeLog.warn(message);
- }
-
- @Override
- public void warn(Object message, Throwable t) {
- bridgeLog.warn(message, t);
- }
-}
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 bcaee8a093..90899b3069 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,4 +30,11 @@ public @interface LogMessage {
String value();
+ public static enum Level {
+ FATAL, ERROR, WARN, INFO, DEBUG, TRACE;
+
+ private Level() {
+ }
+ }
+
}
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerNewLogger.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerNewLogger.java
index db6070f923..ca1e80bd8f 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerNewLogger.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerNewLogger.java
@@ -23,9 +23,12 @@ import org.apache.activemq.artemis.logprocessor.annotation.LogMessage;
@ArtemisBundle(projectCode = "AMQ")
public interface ActiveMQServerNewLogger {
+ /**
+ * The default logger.
+ */
ActiveMQServerNewLogger LOGGER = CodeFactory.getMessageLogger(ActiveMQServerNewLogger.class);
@LogMessage(id = 223000, value = "This is great, {0}")
- void simpleTest(String message);
+ void simpleTest(String componentClassName);
}