Ejemplo n.º 1
0
 /**
  * For formatted messages, first substitute arguments and then log.
  *
  * @param level
  * @param format
  * @param arguments a list of 3 ore more arguments
  */
 private void formatAndLog(int level, String format, Object... arguments) {
   if (!isLevelEnabled(level)) {
     return;
   }
   FormattingTuple tp = MessageFormatter.arrayFormat(format, arguments);
   log(level, tp.getMessage(), tp.getThrowable());
 }
 public double slf4jMessageFormatter_TwoArg(long len) {
   long start = System.nanoTime();
   for (int i = 0; i < len; i++) {
     final FormattingTuple tp =
         MessageFormatter.format("This is some {} short message {} ", i1, i2);
     tp.getMessage();
     tp.getArgArray();
     tp.getThrowable();
   }
   long end = System.nanoTime();
   return (end - start) / (1000 * 1000.0);
 }
Ejemplo n.º 3
0
 /**
  * Log a message at the TRACE level according to the specified format and arguments.
  *
  * <p>This form avoids superfluous object creation when the logger is disabled for the TRACE
  * level.
  *
  * @param format the format string
  * @param arg1 the first argument
  * @param arg2 the second argument
  */
 public void trace(String format, Object arg1, Object arg2) {
   if (m_delegate.isTraceEnabled()) {
     FormattingTuple tuple = MessageFormatter.format(format, arg1, arg2);
     m_delegate.trace(tuple.getMessage(), tuple.getThrowable());
   }
 }
Ejemplo n.º 4
0
 /**
  * This method is similar to {@link #error(String, Object[])} method except that the marker data
  * is also taken into consideration.
  *
  * @param marker the marker data specific to this log statement
  * @param format the format string
  * @param argArray an array of arguments
  */
 public void error(Marker marker, String format, Object[] argArray) {
   if (m_delegate.isErrorEnabled()) {
     FormattingTuple tuple = MessageFormatter.arrayFormat(format, argArray);
     m_delegate.error(tuple.getMessage(), tuple.getThrowable());
   }
 }
Ejemplo n.º 5
0
 /**
  * Log a message at the ERROR level according to the specified format and argument.
  *
  * <p>This form avoids superfluous object creation when the logger is disabled for the ERROR
  * level.
  *
  * @param format the format string
  * @param arg the argument
  */
 public void error(String format, Object arg) {
   if (m_delegate.isErrorEnabled()) {
     FormattingTuple tuple = MessageFormatter.format(format, arg);
     m_delegate.error(tuple.getMessage(), tuple.getThrowable());
   }
 }
Ejemplo n.º 6
0
 /**
  * This method is similar to {@link #warn(String, Object, Object)} method except that the marker
  * data is also taken into consideration.
  *
  * @param marker the marker data specific to this log statement
  * @param format the format string
  * @param arg1 the first argument
  * @param arg2 the second argument
  */
 public void warn(Marker marker, String format, Object arg1, Object arg2) {
   if (m_delegate.isWarnEnabled()) {
     FormattingTuple tuple = MessageFormatter.format(format, arg1, arg2);
     m_delegate.warn(tuple.getMessage(), tuple.getThrowable());
   }
 }
Ejemplo n.º 7
0
 /**
  * Log a message at the WARN level according to the specified format and arguments.
  *
  * <p>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
  */
 public void warn(String format, Object[] argArray) {
   if (m_delegate.isWarnEnabled()) {
     FormattingTuple tuple = MessageFormatter.arrayFormat(format, argArray);
     m_delegate.warn(tuple.getMessage(), tuple.getThrowable());
   }
 }
Ejemplo n.º 8
0
 /**
  * This method is similar to {@link #info(String, Object)} method except that the marker data is
  * also taken into consideration.
  *
  * @param marker the marker data specific to this log statement
  * @param format the format string
  * @param arg the argument
  */
 public void info(Marker marker, String format, Object arg) {
   if (m_delegate.isInfoEnabled()) {
     FormattingTuple tuple = MessageFormatter.format(format, arg);
     m_delegate.inform(tuple.getMessage(), tuple.getThrowable());
   }
 }
Ejemplo n.º 9
0
 /**
  * Log a message at the DEBUG level according to the specified format and argument.
  *
  * <p>This form avoids superfluous object creation when the logger is disabled for the DEBUG
  * level.
  *
  * @param format the format string
  * @param arg the argument
  */
 public void debug(String format, Object arg) {
   if (m_delegate.isDebugEnabled()) {
     FormattingTuple tuple = MessageFormatter.format(format, arg);
     m_delegate.debug(tuple.getMessage(), tuple.getThrowable());
   }
 }
Ejemplo n.º 10
0
 private void formatAndLog(int priority, String format, Object... argArray) {
   if (isLoggable(priority)) {
     FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray);
     logInternal(priority, ft.getMessage(), ft.getThrowable());
   }
 }