diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/util/logging/Logger.java b/xwork-core/src/main/java/com/opensymphony/xwork2/util/logging/Logger.java index d9fc1fb46..87bf77cde 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/util/logging/Logger.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/util/logging/Logger.java @@ -20,26 +20,40 @@ package com.opensymphony.xwork2.util.logging; */ public interface Logger { void trace(String msg, String... args); + void trace(String msg, Throwable ex, String... args); + boolean isTraceEnabled(); - + void debug(String msg, String... args); + + void debug(String msg, Object... args); + void debug(String msg, Throwable ex, String... args); + boolean isDebugEnabled(); - + void info(String msg, String... args); + void info(String msg, Throwable ex, String... args); + boolean isInfoEnabled(); - + void warn(String msg, String... args); + void warn(String msg, Throwable ex, String... args); + boolean isWarnEnabled(); - + void error(String msg, String... args); + void error(String msg, Throwable ex, String... args); + boolean isErrorEnabled(); - + void fatal(String msg, String... args); + void fatal(String msg, Throwable ex, String... args); + boolean isFatalEnabled(); } diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/util/logging/LoggerUtils.java b/xwork-core/src/main/java/com/opensymphony/xwork2/util/logging/LoggerUtils.java index 72726f69f..876b2c73d 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/util/logging/LoggerUtils.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/util/logging/LoggerUtils.java @@ -15,6 +15,9 @@ */ package com.opensymphony.xwork2.util.logging; +import java.util.LinkedList; +import java.util.List; + /** * Logging utility methods */ @@ -69,4 +72,12 @@ public class LoggerUtils { } + public static String format(String msg, Object[] args) { + List strArgs = new LinkedList(); + for (Object arg : args) { + strArgs.add(arg != null ? arg.toString() : "(null)"); + } + return format(msg, strArgs.toArray(new String[strArgs.size()])); + } + } diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/util/logging/commons/CommonsLogger.java b/xwork-core/src/main/java/com/opensymphony/xwork2/util/logging/commons/CommonsLogger.java index 9e88930fa..d167c8be5 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/util/logging/commons/CommonsLogger.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/util/logging/commons/CommonsLogger.java @@ -68,6 +68,10 @@ public class CommonsLogger implements Logger { log.debug(LoggerUtils.format(msg, args)); } + public void debug(String msg, Object... args) { + log.debug(LoggerUtils.format(msg, args)); + } + public void debug(String msg, Throwable ex, String... args) { log.debug(LoggerUtils.format(msg, args), ex); } diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/util/logging/jdk/JdkLogger.java b/xwork-core/src/main/java/com/opensymphony/xwork2/util/logging/jdk/JdkLogger.java index 2aaec2470..8653235ca 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/util/logging/jdk/JdkLogger.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/util/logging/jdk/JdkLogger.java @@ -75,6 +75,10 @@ public class JdkLogger implements Logger { log.log(Level.FINE, LoggerUtils.format(msg, args)); } + public void debug(String msg, Object... args) { + log.log(Level.FINE, LoggerUtils.format(msg, args)); + } + public void debug(String msg, Throwable ex, String... args) { log.log(Level.FINE, LoggerUtils.format(msg, args), ex); } diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/util/logging/slf4j/Slf4jLogger.java b/xwork-core/src/main/java/com/opensymphony/xwork2/util/logging/slf4j/Slf4jLogger.java index d0f1237a8..f3c812b99 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/util/logging/slf4j/Slf4jLogger.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/util/logging/slf4j/Slf4jLogger.java @@ -45,8 +45,6 @@ public class Slf4jLogger implements Logger { log.info(LoggerUtils.format(msg, args), ex); } - - public boolean isInfoEnabled() { return log.isInfoEnabled(); } @@ -67,6 +65,10 @@ public class Slf4jLogger implements Logger { log.debug(LoggerUtils.format(msg, args)); } + public void debug(String msg, Object... args) { + log.debug(LoggerUtils.format(msg, args)); + } + public void debug(String msg, Throwable ex, String... args) { log.debug(LoggerUtils.format(msg, args), ex); }