Adds support for debug(String, Object...)

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@1436984 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Lukasz Lenart
2013-01-22 14:55:59 +00:00
parent 3f1f9a133b
commit ebc33bc718
5 changed files with 42 additions and 7 deletions
@@ -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();
}
@@ -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<String> strArgs = new LinkedList<String>();
for (Object arg : args) {
strArgs.add(arg != null ? arg.toString() : "(null)");
}
return format(msg, strArgs.toArray(new String[strArgs.size()]));
}
}
@@ -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);
}
@@ -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);
}
@@ -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);
}