ARTEMIS-2732 Bridging Apache Logger into JBoss Logging for the testsuite

This commit is contained in:
Clebert Suconic 2020-04-23 13:19:31 -04:00
parent e8d23f3144
commit 77d250bec8
3 changed files with 266 additions and 1 deletions

View File

@ -0,0 +1,134 @@
/*
* 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.jboss.logging.Logger;
/**
* 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 = Logger.getLogger(clazz);
}
public JBossLoggingApacheLoggerBridge(String name) {
bridgeLog = Logger.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);
}
}

View File

@ -175,7 +175,7 @@
-->
<activemq-surefire-argline>-Dorg.apache.activemq.artemis.utils.RetryRule.retry=${retryTests} -Dbrokerconfig.maxDiskUsage=100 -Dorg.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.DEFAULT_QUIET_PERIOD=0 -Dorg.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.DEFAULT_SHUTDOWN_TIMEOUT=0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager
<activemq-surefire-argline>-Dorg.apache.commons.logging.Log=org.apache.activemq.artemis.logs.JBossLoggingApacheLoggerBridge -Dorg.apache.activemq.artemis.utils.RetryRule.retry=${retryTests} -Dbrokerconfig.maxDiskUsage=100 -Dorg.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.DEFAULT_QUIET_PERIOD=0 -Dorg.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.DEFAULT_SHUTDOWN_TIMEOUT=0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager
-Dlogging.configuration="file:${activemq.basedir}/tests/config/${logging.config}"
-Djava.library.path="${activemq.basedir}/target/bin/lib/linux-x86_64:${activemq.basedir}/target/bin/lib/linux-i686" -Djgroups.bind_addr=localhost -Dorg.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory.localBindAddress=localhost
-Djava.net.preferIPv4Stack=true -Dbasedir=${basedir}

View File

@ -0,0 +1,131 @@
/*
* 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.jboss.logging.Logger;
/**
* This is a necessary copy of the JBossLoggingApacheLoggerBridge on artemis-commons package.
* Since we define -Dorg.apache.commons.logging.Log=org.apache.activemq.artemis.logs.JBossLoggingApacheLoggerBridge
* We need to have the class defined.
* However I cannot import commons into older versions.
* For that reason this class was needed as a duplicate.
* */
public class JBossLoggingApacheLoggerBridge implements Log {
final Logger bridgeLog;
public JBossLoggingApacheLoggerBridge(Class clazz) {
bridgeLog = Logger.getLogger(clazz);
}
public JBossLoggingApacheLoggerBridge(String name) {
bridgeLog = Logger.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);
}
}