- * This form avoids superfluous object creation when the logger is disabled - * for level TRACE. - *
- * - * @param format - * the format string - * @param arg - * the argument - */ - @Override - public void trace(String format, Object arg) { - if (isTraceEnabled()) { - FormattingTuple ft = MessageFormatter.format(format, arg); - logger.log(FQCN, traceCapable ? Level.TRACE : Level.DEBUG, ft - .getMessage(), ft.getThrowable()); - } - } - - /** - * Log a message at level TRACE according to the specified format and - * arguments. - * - *- * This form avoids superfluous object creation when the logger is disabled - * for the TRACE level. - *
- * - * @param format - * the format string - * @param argA - * the first argument - * @param argB - * the second argument - */ - @Override - public void trace(String format, Object argA, Object argB) { - if (isTraceEnabled()) { - FormattingTuple ft = MessageFormatter.format(format, argA, argB); - logger.log(FQCN, traceCapable ? Level.TRACE : Level.DEBUG, ft - .getMessage(), ft.getThrowable()); - } - } - - /** - * Log a message at level TRACE according to the specified format and - * arguments. - * - *- * This form avoids superfluous object creation when the logger is disabled - * for the TRACE level. - *
- * - * @param format - * the format string - * @param arguments - * an array of arguments - */ - @Override - public void trace(String format, Object... arguments) { - if (isTraceEnabled()) { - FormattingTuple ft = MessageFormatter.arrayFormat(format, arguments); - logger.log(FQCN, traceCapable ? Level.TRACE : Level.DEBUG, ft - .getMessage(), ft.getThrowable()); - } - } - - /** - * Log an exception (throwable) at level TRACE with an accompanying message. - * - * @param msg - * the message accompanying the exception - * @param t - * the exception (throwable) to log - */ - @Override - public void trace(String msg, Throwable t) { - logger.log(FQCN, traceCapable ? Level.TRACE : Level.DEBUG, msg, t); - } - - /** - * Is this logger instance enabled for the DEBUG level? - * - * @return True if this Logger is enabled for level DEBUG, false otherwise. - */ - @Override - public boolean isDebugEnabled() { - return logger.isDebugEnabled(); - } - - /** - * Log a message object at level DEBUG. - * - * @param msg - * - the message object to be logged - */ - @Override - public void debug(String msg) { - logger.log(FQCN, Level.DEBUG, msg, null); - } - - /** - * Log a message at level DEBUG according to the specified format and - * argument. - * - *- * This form avoids superfluous object creation when the logger is disabled - * for level DEBUG. - *
- * - * @param format - * the format string - * @param arg - * the argument - */ - @Override - public void debug(String format, Object arg) { - if (logger.isDebugEnabled()) { - FormattingTuple ft = MessageFormatter.format(format, arg); - logger.log(FQCN, Level.DEBUG, ft.getMessage(), ft.getThrowable()); - } - } - - /** - * Log a message at level DEBUG according to the specified format and - * arguments. - * - *- * This form avoids superfluous object creation when the logger is disabled - * for the DEBUG level. - *
- * - * @param format - * the format string - * @param argA - * the first argument - * @param argB - * the second argument - */ - @Override - public void debug(String format, Object argA, Object argB) { - if (logger.isDebugEnabled()) { - FormattingTuple ft = MessageFormatter.format(format, argA, argB); - logger.log(FQCN, Level.DEBUG, ft.getMessage(), ft.getThrowable()); - } - } - - /** - * Log a message at level DEBUG according to the specified format and - * arguments. - * - *- * This form avoids superfluous object creation when the logger is disabled - * for the DEBUG level. - *
- * - * @param format - * the format string - * @param arguments an array of arguments - */ - @Override - public void debug(String format, Object... arguments) { - if (logger.isDebugEnabled()) { - FormattingTuple ft = MessageFormatter.arrayFormat(format, arguments); - logger.log(FQCN, Level.DEBUG, ft.getMessage(), ft.getThrowable()); - } - } - - /** - * Log an exception (throwable) at level DEBUG with an accompanying message. - * - * @param msg - * the message accompanying the exception - * @param t - * the exception (throwable) to log - */ - @Override - public void debug(String msg, Throwable t) { - logger.log(FQCN, Level.DEBUG, msg, t); - } - - /** - * Is this logger instance enabled for the INFO level? - * - * @return True if this Logger is enabled for the INFO level, false otherwise. - */ - @Override - public boolean isInfoEnabled() { - return logger.isInfoEnabled(); - } - - /** - * Log a message object at the INFO level. - * - * @param msg - * - the message object to be logged - */ - @Override - public void info(String msg) { - logger.log(FQCN, Level.INFO, msg, null); - } - - /** - * Log a message at level INFO according to the specified format and argument. - * - *- * This form avoids superfluous object creation when the logger is disabled - * for the INFO level. - *
- * - * @param format - * the format string - * @param arg - * the argument - */ - @Override - public void info(String format, Object arg) { - if (logger.isInfoEnabled()) { - FormattingTuple ft = MessageFormatter.format(format, arg); - logger.log(FQCN, Level.INFO, ft.getMessage(), ft.getThrowable()); - } - } - - /** - * Log a message at the INFO level according to the specified format and - * arguments. - * - *- * This form avoids superfluous object creation when the logger is disabled - * for the INFO level. - *
- * - * @param format - * the format string - * @param argA - * the first argument - * @param argB - * the second argument - */ - @Override - public void info(String format, Object argA, Object argB) { - if (logger.isInfoEnabled()) { - FormattingTuple ft = MessageFormatter.format(format, argA, argB); - logger.log(FQCN, Level.INFO, ft.getMessage(), ft.getThrowable()); - } - } - - /** - * Log a message at level INFO according to the specified format and - * arguments. - * - *- * This form avoids superfluous object creation when the logger is disabled - * for the INFO level. - *
- * - * @param format - * the format string - * @param argArray - * an array of arguments - */ - @Override - public void info(String format, Object... argArray) { - if (logger.isInfoEnabled()) { - FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray); - logger.log(FQCN, Level.INFO, ft.getMessage(), ft.getThrowable()); - } - } - - /** - * Log an exception (throwable) at the INFO level with an accompanying - * message. - * - * @param msg - * the message accompanying the exception - * @param t - * the exception (throwable) to log - */ - @Override - public void info(String msg, Throwable t) { - logger.log(FQCN, Level.INFO, msg, t); - } - - /** - * Is this logger instance enabled for the WARN level? - * - * @return True if this Logger is enabled for the WARN level, false otherwise. - */ - @Override - public boolean isWarnEnabled() { - return logger.isEnabledFor(Level.WARN); - } - - /** - * Log a message object at the WARN level. - * - * @param msg - * - the message object to be logged - */ - @Override - public void warn(String msg) { - logger.log(FQCN, Level.WARN, msg, null); - } - - /** - * Log a message at the WARN level according to the specified format and - * argument. - * - *- * This form avoids superfluous object creation when the logger is disabled - * for the WARN level. - *
- * - * @param format - * the format string - * @param arg - * the argument - */ - @Override - public void warn(String format, Object arg) { - if (logger.isEnabledFor(Level.WARN)) { - FormattingTuple ft = MessageFormatter.format(format, arg); - logger.log(FQCN, Level.WARN, ft.getMessage(), ft.getThrowable()); - } - } - - /** - * Log a message at the WARN level according to the specified format and - * arguments. - * - *- * This form avoids superfluous object creation when the logger is disabled - * for the WARN level. - *
- * - * @param format - * the format string - * @param argA - * the first argument - * @param argB - * the second argument - */ - @Override - public void warn(String format, Object argA, Object argB) { - if (logger.isEnabledFor(Level.WARN)) { - FormattingTuple ft = MessageFormatter.format(format, argA, argB); - logger.log(FQCN, Level.WARN, ft.getMessage(), ft.getThrowable()); - } - } - - /** - * Log a message at level WARN according to the specified format and - * arguments. - * - *- * This form avoids superfluous object creation when the logger is disabled - * for the WARN level. - *
- * - * @param format - * the format string - * @param argArray - * an array of arguments - */ - @Override - public void warn(String format, Object... argArray) { - if (logger.isEnabledFor(Level.WARN)) { - FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray); - logger.log(FQCN, Level.WARN, ft.getMessage(), ft.getThrowable()); - } - } - - /** - * Log an exception (throwable) at the WARN level with an accompanying - * message. - * - * @param msg - * the message accompanying the exception - * @param t - * the exception (throwable) to log - */ - @Override - public void warn(String msg, Throwable t) { - logger.log(FQCN, Level.WARN, msg, t); - } - - /** - * Is this logger instance enabled for level ERROR? - * - * @return True if this Logger is enabled for level ERROR, false otherwise. - */ - @Override - public boolean isErrorEnabled() { - return logger.isEnabledFor(Level.ERROR); - } - - /** - * Log a message object at the ERROR level. - * - * @param msg - * - the message object to be logged - */ - @Override - public void error(String msg) { - logger.log(FQCN, Level.ERROR, msg, null); - } - - /** - * Log a message at the ERROR level according to the specified format and - * argument. - * - *- * This form avoids superfluous object creation when the logger is disabled - * for the ERROR level. - *
- * - * @param format - * the format string - * @param arg - * the argument - */ - @Override - public void error(String format, Object arg) { - if (logger.isEnabledFor(Level.ERROR)) { - FormattingTuple ft = MessageFormatter.format(format, arg); - logger.log(FQCN, Level.ERROR, ft.getMessage(), ft.getThrowable()); - } - } - - /** - * Log a message at the ERROR level according to the specified format and - * arguments. - * - *- * This form avoids superfluous object creation when the logger is disabled - * for the ERROR level. - *
- * - * @param format - * the format string - * @param argA - * the first argument - * @param argB - * the second argument - */ - @Override - public void error(String format, Object argA, Object argB) { - if (logger.isEnabledFor(Level.ERROR)) { - FormattingTuple ft = MessageFormatter.format(format, argA, argB); - logger.log(FQCN, Level.ERROR, ft.getMessage(), ft.getThrowable()); - } - } - - /** - * Log a message at level ERROR according to the specified format and - * arguments. - * - *- * This form avoids superfluous object creation when the logger is disabled - * for the ERROR level. - *
- * - * @param format - * the format string - * @param argArray - * an array of arguments - */ - @Override - public void error(String format, Object... argArray) { - if (logger.isEnabledFor(Level.ERROR)) { - FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray); - logger.log(FQCN, Level.ERROR, ft.getMessage(), ft.getThrowable()); - } - } - - /** - * Log an exception (throwable) at the ERROR level with an accompanying - * message. - * - * @param msg - * the message accompanying the exception - * @param t - * the exception (throwable) to log - */ - @Override - public void error(String msg, Throwable t) { - logger.log(FQCN, Level.ERROR, msg, t); - } -} diff --git a/common/src/main/java/io/netty/util/internal/logging/Log4JLoggerFactory.java b/common/src/main/java/io/netty/util/internal/logging/Log4JLoggerFactory.java deleted file mode 100644 index 3d56907f38d..00000000000 --- a/common/src/main/java/io/netty/util/internal/logging/Log4JLoggerFactory.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2012 The Netty Project - * - * The Netty Project 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: - * - * https://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 io.netty.util.internal.logging; - -import org.apache.log4j.Logger; - -/** - * Logger factory which creates an - * Apache Log4J - * logger. - */ -public class Log4JLoggerFactory extends InternalLoggerFactory { - - public static final InternalLoggerFactory INSTANCE = new Log4JLoggerFactory(); - - /** - * @deprecated Use {@link #INSTANCE} instead. - */ - @Deprecated - public Log4JLoggerFactory() { - } - - @Override - public InternalLogger newInstance(String name) { - return new Log4JLogger(Logger.getLogger(name)); - } -} diff --git a/common/src/test/java/io/netty/util/internal/logging/Log4JLoggerFactoryTest.java b/common/src/test/java/io/netty/util/internal/logging/Log4JLoggerFactoryTest.java deleted file mode 100644 index 00db0b0cdda..00000000000 --- a/common/src/test/java/io/netty/util/internal/logging/Log4JLoggerFactoryTest.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2012 The Netty Project - * - * The Netty Project 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: - * - * https://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 io.netty.util.internal.logging; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class Log4JLoggerFactoryTest { - - @Test - public void testCreation() { - InternalLogger logger = Log4JLoggerFactory.INSTANCE.newInstance("foo"); - assertTrue(logger instanceof Log4JLogger); - assertEquals("foo", logger.name()); - } -} diff --git a/pom.xml b/pom.xml index 5846c811993..a656e4dc8de 100644 --- a/pom.xml +++ b/pom.xml @@ -686,30 +686,6 @@