415131 Avoid autoboxing on debug

This commit is contained in:
Greg Wilkins 2013-08-15 18:52:31 +10:00
parent 145f544861
commit 484aa94cd0
6 changed files with 53 additions and 0 deletions

View File

@ -75,4 +75,10 @@ public abstract class AbstractLogger implements Logger
}
return true;
}
public void debug(String msg, long arg)
{
if (isDebugEnabled())
debug(msg,new Long(arg));
}
}

View File

@ -111,6 +111,12 @@ public class JavaUtilLog extends AbstractLogger
_logger.log(Level.FINE,format(msg, args));
}
public void debug(String msg, long arg)
{
if (_logger.isLoggable(Level.FINE))
_logger.log(Level.FINE,format(msg, arg));
}
public void debug(Throwable thrown)
{
debug("", thrown);

View File

@ -85,6 +85,15 @@ public interface Logger
* @param args the optional arguments
*/
public void debug(String msg, Object... args);
/**
* Formats and logs at debug level.
* avoids autoboxing of integers
* @param msg the formatting string
* @param args the optional arguments
*/
public void debug(String msg, long value);
/**
* Logs the given Throwable information at debug level

View File

@ -151,6 +151,7 @@ public class LoggerLog extends AbstractLogger
}
}
public void debug(String msg, Object... args)
{
if (!_debug)
@ -186,6 +187,21 @@ public class LoggerLog extends AbstractLogger
}
}
public void debug(String msg, long value)
{
if (!_debug)
return;
try
{
_debugMAA.invoke(_logger, new Object[]{new Long(value)});
}
catch (Exception e)
{
e.printStackTrace();
}
}
public void ignore(Throwable ignored)
{
if (Log.isIgnored())

View File

@ -88,6 +88,12 @@ public class Slf4jLog extends AbstractLogger
{
_logger.debug(msg, args);
}
public void debug(String msg, long arg)
{
if (isDebugEnabled())
_logger.debug(msg, new Object[]{new Long(arg)});
}
public void debug(Throwable thrown)
{

View File

@ -519,6 +519,16 @@ public class StdErrLog extends AbstractLogger
}
}
public void debug(String msg, long arg)
{
if (isDebugEnabled())
{
StringBuilder buffer = new StringBuilder(64);
format(buffer,":DBUG:",msg,arg);
(_stderr==null?System.err:_stderr).println(buffer);
}
}
public void debug(Throwable thrown)
{
debug("",thrown);