Java Code Examples for org.slf4j.helpers.MessageFormatter#format()

The following examples show how to use org.slf4j.helpers.MessageFormatter#format() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LogUtils.java    From openzaly with Apache License 2.0 4 votes vote down vote up
public static void info(org.apache.log4j.Logger logger, String messagePattern, Object object) {
	FormattingTuple format = MessageFormatter.format(messagePattern, object);
	logger.info(format.getMessage());
}
 
Example 2
Source File: LogUtils.java    From wind-im with Apache License 2.0 4 votes vote down vote up
public static void info(org.apache.log4j.Logger logger, String messagePattern, Object object) {
	FormattingTuple format = MessageFormatter.format(messagePattern, object);
	logger.info(format.getMessage());
}
 
Example 3
Source File: MycatLogger.java    From Mycat2 with GNU General Public License v3.0 4 votes vote down vote up
public ErrorPacketImpl errorPacket(int error, String s, Object o) {
  FormattingTuple ft = MessageFormatter.format(s, o);
  logger.error(ft.getMessage(), ft.getThrowable());
  return getErrorPacket(ft.getMessage(), error);
}
 
Example 4
Source File: Log4jLoggerAdapter.java    From HttpSessionReplacer with MIT License 3 votes vote down vote up
/**
 * Log a message at level DEBUG according to the specified format and
 * arguments.
 *
 * <p>
 * This form avoids superfluous object creation when the logger is disabled
 * for the DEBUG level.
 * </p>
 *
 * @param format
 *          the format string
 * @param arg1
 *          the first argument
 * @param arg2
 *          the second argument
 */
@Override
public void debug(String format, Object arg1, Object arg2) {
    if (logger.isDebugEnabled()) {
        FormattingTuple ft = MessageFormatter.format(format, arg1, arg2);
        logger.log(FQCN, Level.DEBUG, ft.getMessage(), ft.getThrowable());
    }
}
 
Example 5
Source File: JDK14LoggerAdapter.java    From HttpSessionReplacer with MIT License 3 votes vote down vote up
/**
 * Log a message at level INFO according to the specified format and argument.
 *
 * <p>
 * This form avoids superfluous object creation when the logger is disabled
 * for the INFO level.
 * </p>
 *
 * @param format
 *          the format string
 * @param arg
 *          the argument
 */
@Override
public void info(String format, Object arg) {
    if (logger.isLoggable(Level.INFO)) {
        FormattingTuple ft = MessageFormatter.format(format, arg);
        log(SELF, Level.INFO, ft.getMessage(), ft.getThrowable());
    }
}
 
Example 6
Source File: Log4jLoggerAdapter.java    From HttpSessionReplacer with MIT License 3 votes vote down vote up
/**
 * Log a message at level TRACE according to the specified format and
 * arguments.
 *
 * <p>
 * This form avoids superfluous object creation when the logger is disabled
 * for the TRACE level.
 * </p>
 *
 * @param format
 *          the format string
 * @param arg1
 *          the first argument
 * @param arg2
 *          the second argument
 */
@Override
public void trace(String format, Object arg1, Object arg2) {
    if (isTraceEnabled()) {
        FormattingTuple ft = MessageFormatter.format(format, arg1, arg2);
        logger.log(FQCN, traceCapable ? Level.TRACE : Level.DEBUG, ft.getMessage(), ft.getThrowable());
    }
}
 
Example 7
Source File: Log4jLoggerAdapter.java    From HttpSessionReplacer with MIT License 3 votes vote down vote up
/**
 * Log a message at the INFO level according to the specified format and
 * arguments.
 *
 * <p>
 * This form avoids superfluous object creation when the logger is disabled
 * for the INFO level.
 * </p>
 *
 * @param format
 *          the format string
 * @param arg1
 *          the first argument
 * @param arg2
 *          the second argument
 */
@Override
public void info(String format, Object arg1, Object arg2) {
    if (logger.isInfoEnabled()) {
        FormattingTuple ft = MessageFormatter.format(format, arg1, arg2);
        logger.log(FQCN, Level.INFO, ft.getMessage(), ft.getThrowable());
    }
}
 
Example 8
Source File: SimpleLogger.java    From HttpSessionReplacer with MIT License 3 votes vote down vote up
/**
 * For formatted messages, first substitute arguments and then log.
 *
 * @param level
 * @param format
 * @param arg1
 * @param arg2
 */
private void formatAndLog(int level, String format, Object arg1, Object arg2) {
  if (!isLevelEnabled(level)) {
    return;
  }
  FormattingTuple tp = MessageFormatter.format(format, arg1, arg2);
  log(level, tp.getMessage(), tp.getThrowable());
}
 
Example 9
Source File: JCLLoggerAdapter.java    From HttpSessionReplacer with MIT License 3 votes vote down vote up
/**
 * Delegates to the {@link Log#error(java.lang.Object)} method of the underlying
 * {@link Log} instance.
 *
 * <p>
 * However, this form avoids superfluous object creation when the logger is disabled
 * for level ERROR.
 * </p>
 *
 * @param format
 *          the format string
 * @param arg1
 *          the first argument
 * @param arg2
 *          the second argument
 */
@Override
public void error(String format, Object arg1, Object arg2) {
    if (log.isErrorEnabled()) {
        FormattingTuple ft = MessageFormatter.format(format, arg1, arg2);
        log.error(ft.getMessage(), ft.getThrowable());
    }
}
 
Example 10
Source File: Log4jLoggerAdapter.java    From HttpSessionReplacer with MIT License 3 votes vote down vote up
/**
 * Log a message at level INFO according to the specified format and argument.
 *
 * <p>
 * This form avoids superfluous object creation when the logger is disabled
 * for the INFO level.
 * </p>
 *
 * @param format
 *          the format string
 * @param arg
 *          the argument
 */
@Override
public void info(String format, Object arg) {
    if (logger.isInfoEnabled()) {
        FormattingTuple ft = MessageFormatter.format(format, arg);
        logger.log(FQCN, Level.INFO, ft.getMessage(), ft.getThrowable());
    }
}
 
Example 11
Source File: JCLLoggerAdapter.java    From HttpSessionReplacer with MIT License 3 votes vote down vote up
/**
 * Delegates to the {@link Log#warn(java.lang.Object)} method of the underlying
 * {@link Log} instance.
 *
 * <p>
 * However, this form avoids superfluous object creation when the logger is disabled
 * for level WARN.
 * </p>
 *
 * @param format
 *          the format string
 * @param arg1
 *          the first argument
 * @param arg2
 *          the second argument
 */
@Override
public void warn(String format, Object arg1, Object arg2) {
    if (log.isWarnEnabled()) {
        FormattingTuple ft = MessageFormatter.format(format, arg1, arg2);
        log.warn(ft.getMessage(), ft.getThrowable());
    }
}
 
Example 12
Source File: JCLLoggerAdapter.java    From HttpSessionReplacer with MIT License 3 votes vote down vote up
/**
 * Delegates to the {@link Log#warn(java.lang.Object)} method of the underlying
 * {@link Log} instance.
 *
 * <p>
 * However, this form avoids superfluous object creation when the logger is disabled
 * for level WARN.
 * </p>
 *
 * @param format
 *          the format string
 * @param arg
 *          the argument
 */
@Override
public void warn(String format, Object arg) {
    if (log.isWarnEnabled()) {
        FormattingTuple ft = MessageFormatter.format(format, arg);
        log.warn(ft.getMessage(), ft.getThrowable());
    }
}
 
Example 13
Source File: Log4jLoggerAdapter.java    From HttpSessionReplacer with MIT License 3 votes vote down vote up
/**
 * 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.
 * </p>
 *
 * @param format
 *          the format string
 * @param arg
 *          the argument
 */
@Override
public void error(String format, Object arg) {
    if (logger.isEnabledFor(Level.ERROR)) {
        FormattingTuple ft = MessageFormatter.format(format, arg);
        logger.log(FQCN, Level.ERROR, ft.getMessage(), ft.getThrowable());
    }
}
 
Example 14
Source File: JCLLoggerAdapter.java    From HttpSessionReplacer with MIT License 3 votes vote down vote up
/**
 * Delegates to the {@link Log#info(java.lang.Object)} method of the underlying
 * {@link Log} instance.
 *
 * <p>
 * However, this form avoids superfluous object creation when the logger is disabled
 * for level INFO.
 * </p>
 *
 * @param format
 *          the format string
 * @param arg
 *          the argument
 */

@Override
public void info(String format, Object arg) {
    if (log.isInfoEnabled()) {
        FormattingTuple ft = MessageFormatter.format(format, arg);
        log.info(ft.getMessage(), ft.getThrowable());
    }
}
 
Example 15
Source File: JCLLoggerAdapter.java    From HttpSessionReplacer with MIT License 3 votes vote down vote up
/**
 * Delegates to the {@link Log#debug(java.lang.Object)} method of the underlying
 * {@link Log} instance.
 *
 * <p>
 * However, this form avoids superfluous object creation when the logger is disabled
 * for level DEBUG.
 * </p>
 *
 * @param format
 *          the format string
 * @param arg1
 *          the first argument
 * @param arg2
 *          the second argument
 */
@Override
public void debug(String format, Object arg1, Object arg2) {
    if (log.isDebugEnabled()) {
        FormattingTuple ft = MessageFormatter.format(format, arg1, arg2);
        log.debug(ft.getMessage(), ft.getThrowable());
    }
}
 
Example 16
Source File: Log4jLoggerAdapter.java    From HttpSessionReplacer with MIT License 3 votes vote down vote up
/**
 * Log a message at the WARN level according to the specified format and
 * argument.
 *
 * <p>
 * This form avoids superfluous object creation when the logger is disabled
 * for the WARN level.
 * </p>
 *
 * @param format
 *          the format string
 * @param arg
 *          the argument
 */
@Override
public void warn(String format, Object arg) {
    if (logger.isEnabledFor(Level.WARN)) {
        FormattingTuple ft = MessageFormatter.format(format, arg);
        logger.log(FQCN, Level.WARN, ft.getMessage(), ft.getThrowable());
    }
}
 
Example 17
Source File: JCLLoggerAdapter.java    From HttpSessionReplacer with MIT License 3 votes vote down vote up
/**
 * Delegates to the {@link Log#trace(java.lang.Object)} method of the underlying
 * {@link Log} instance.
 *
 * <p>
 * However, this form avoids superfluous object creation when the logger is disabled
 * for level TRACE.
 * </p>
 *
 * @param format
 *          the format string
 * @param arg1
 *          the first argument
 * @param arg2
 *          the second argument
 */
@Override
public void trace(String format, Object arg1, Object arg2) {
    if (log.isTraceEnabled()) {
        FormattingTuple ft = MessageFormatter.format(format, arg1, arg2);
        log.trace(ft.getMessage(), ft.getThrowable());
    }
}
 
Example 18
Source File: JCLLoggerAdapter.java    From HttpSessionReplacer with MIT License 3 votes vote down vote up
/**
 * Delegates to the {@link Log#trace(java.lang.Object)} method of the underlying
 * {@link Log} instance.
 *
 * <p>
 * However, this form avoids superfluous object creation when the logger is disabled
 * for level TRACE.
 * </p>
 *
 * @param format
 *          the format string
 * @param arg
 *          the argument
 */
@Override
public void trace(String format, Object arg) {
    if (log.isTraceEnabled()) {
        FormattingTuple ft = MessageFormatter.format(format, arg);
        log.trace(ft.getMessage(), ft.getThrowable());
    }
}
 
Example 19
Source File: JDK14LoggerAdapter.java    From HttpSessionReplacer with MIT License 3 votes vote down vote up
/**
 * Log a message at level FINE according to the specified format and
 * arguments.
 *
 * <p>
 * This form avoids superfluous object creation when the logger is disabled
 * for the FINE level.
 * </p>
 *
 * @param format
 *          the format string
 * @param arg1
 *          the first argument
 * @param arg2
 *          the second argument
 */
@Override
public void debug(String format, Object arg1, Object arg2) {
    if (logger.isLoggable(Level.FINE)) {
        FormattingTuple ft = MessageFormatter.format(format, arg1, arg2);
        log(SELF, Level.FINE, ft.getMessage(), ft.getThrowable());
    }
}
 
Example 20
Source File: Log4jLoggerAdapter.java    From HttpSessionReplacer with MIT License 3 votes vote down vote up
/**
 * 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.
 * </p>
 *
 * @param format
 *          the format string
 * @param arg1
 *          the first argument
 * @param arg2
 *          the second argument
 */
@Override
public void warn(String format, Object arg1, Object arg2) {
    if (logger.isEnabledFor(Level.WARN)) {
        FormattingTuple ft = MessageFormatter.format(format, arg1, arg2);
        logger.log(FQCN, Level.WARN, ft.getMessage(), ft.getThrowable());
    }
}