diff --git a/common/src/main/java/io/netty/util/internal/logging/AbstractInternalLogger.java b/common/src/main/java/io/netty/util/internal/logging/AbstractInternalLogger.java index afb45b21d4..f0fcdce8a9 100644 --- a/common/src/main/java/io/netty/util/internal/logging/AbstractInternalLogger.java +++ b/common/src/main/java/io/netty/util/internal/logging/AbstractInternalLogger.java @@ -29,6 +29,8 @@ public abstract class AbstractInternalLogger implements InternalLogger, Serializ private static final long serialVersionUID = -6382972526573193470L; + private static final String EXCEPTION_MESSAGE = "Unexpected exception:"; + private final String name; /** @@ -64,6 +66,32 @@ public abstract class AbstractInternalLogger implements InternalLogger, Serializ } } + @Override + public void trace(Throwable t) { + trace(EXCEPTION_MESSAGE, t); + } + + @Override + public void debug(Throwable t) { + debug(EXCEPTION_MESSAGE, t); + } + + @Override + public void info(Throwable t) { + info(EXCEPTION_MESSAGE, t); + + } + + @Override + public void warn(Throwable t) { + warn(EXCEPTION_MESSAGE, t); + } + + @Override + public void error(Throwable t) { + error(EXCEPTION_MESSAGE, t); + } + @Override public void log(InternalLogLevel level, String msg, Throwable cause) { switch (level) { @@ -87,6 +115,29 @@ public abstract class AbstractInternalLogger implements InternalLogger, Serializ } } + @Override + public void log(InternalLogLevel level, Throwable cause) { + switch (level) { + case TRACE: + trace(cause); + break; + case DEBUG: + debug(cause); + break; + case INFO: + info(cause); + break; + case WARN: + warn(cause); + break; + case ERROR: + error(cause); + break; + default: + throw new Error(); + } + } + @Override public void log(InternalLogLevel level, String msg) { switch (level) { diff --git a/common/src/main/java/io/netty/util/internal/logging/InternalLogger.java b/common/src/main/java/io/netty/util/internal/logging/InternalLogger.java index 6cb274f5be..335cf32ee7 100644 --- a/common/src/main/java/io/netty/util/internal/logging/InternalLogger.java +++ b/common/src/main/java/io/netty/util/internal/logging/InternalLogger.java @@ -116,6 +116,13 @@ public interface InternalLogger { */ void trace(String msg, Throwable t); + /** + * Log an exception (throwable) at the TRACE level. + * + * @param t the exception (throwable) to log + */ + void trace(Throwable t); + /** * Is the logger instance enabled for the DEBUG level? * @@ -181,6 +188,13 @@ public interface InternalLogger { */ void debug(String msg, Throwable t); + /** + * Log an exception (throwable) at the DEBUG level. + * + * @param t the exception (throwable) to log + */ + void debug(Throwable t); + /** * Is the logger instance enabled for the INFO level? * @@ -246,6 +260,13 @@ public interface InternalLogger { */ void info(String msg, Throwable t); + /** + * Log an exception (throwable) at the INFO level. + * + * @param t the exception (throwable) to log + */ + void info(Throwable t); + /** * Is the logger instance enabled for the WARN level? * @@ -311,6 +332,13 @@ public interface InternalLogger { */ void warn(String msg, Throwable t); + /** + * Log an exception (throwable) at the WARN level. + * + * @param t the exception (throwable) to log + */ + void warn(Throwable t); + /** * Is the logger instance enabled for the ERROR level? * @@ -376,6 +404,13 @@ public interface InternalLogger { */ void error(String msg, Throwable t); + /** + * Log an exception (throwable) at the ERROR level. + * + * @param t the exception (throwable) to log + */ + void error(Throwable t); + /** * Is the logger instance enabled for the specified {@code level}? * @@ -441,4 +476,11 @@ public interface InternalLogger { * @param t the exception (throwable) to log */ void log(InternalLogLevel level, String msg, Throwable t); + + /** + * Log an exception (throwable) at the specified {@code level}. + * + * @param t the exception (throwable) to log + */ + void log(InternalLogLevel level, Throwable t); }