org.slf4j.helpers.MessageFormatter#format ( )源码实例Demo

下面列出了org.slf4j.helpers.MessageFormatter#format ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: wind-im   文件: LogUtils.java
public static void info(org.apache.log4j.Logger logger, String messagePattern, Object object) {
	FormattingTuple format = MessageFormatter.format(messagePattern, object);
	logger.info(format.getMessage());
}
 
源代码2 项目: openzaly   文件: LogUtils.java
public static void info(org.apache.log4j.Logger logger, String messagePattern, Object object) {
	FormattingTuple format = MessageFormatter.format(messagePattern, object);
	logger.info(format.getMessage());
}
 
源代码3 项目: Mycat2   文件: MycatLogger.java
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);
}
 
源代码4 项目: HttpSessionReplacer   文件: Log4jLoggerAdapter.java
/**
 * 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());
    }
}
 
源代码5 项目: HttpSessionReplacer   文件: JDK14LoggerAdapter.java
/**
 * 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());
    }
}
 
源代码6 项目: HttpSessionReplacer   文件: JCLLoggerAdapter.java
/**
 * 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());
    }
}
 
源代码7 项目: HttpSessionReplacer   文件: JCLLoggerAdapter.java
/**
 * 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());
    }
}
 
源代码8 项目: HttpSessionReplacer   文件: Log4jLoggerAdapter.java
/**
 * 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());
    }
}
 
源代码9 项目: HttpSessionReplacer   文件: JCLLoggerAdapter.java
/**
 * 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());
    }
}
 
源代码10 项目: HttpSessionReplacer   文件: JCLLoggerAdapter.java
/**
 * 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());
    }
}
 
源代码11 项目: HttpSessionReplacer   文件: Log4jLoggerAdapter.java
/**
 * 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());
    }
}
 
源代码12 项目: HttpSessionReplacer   文件: JCLLoggerAdapter.java
/**
 * 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());
    }
}
 
源代码13 项目: HttpSessionReplacer   文件: JCLLoggerAdapter.java
/**
 * 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());
    }
}
 
源代码14 项目: HttpSessionReplacer   文件: Log4jLoggerAdapter.java
/**
 * 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());
    }
}
 
源代码15 项目: HttpSessionReplacer   文件: JCLLoggerAdapter.java
/**
 * 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());
    }
}
 
源代码16 项目: HttpSessionReplacer   文件: SimpleLogger.java
/**
 * 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());
}
 
源代码17 项目: HttpSessionReplacer   文件: Log4jLoggerAdapter.java
/**
 * 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());
    }
}
 
源代码18 项目: HttpSessionReplacer   文件: Log4jLoggerAdapter.java
/**
 * 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());
    }
}
 
源代码19 项目: HttpSessionReplacer   文件: JDK14LoggerAdapter.java
/**
 * 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());
    }
}
 
源代码20 项目: HttpSessionReplacer   文件: Log4jLoggerAdapter.java
/**
 * 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());
    }
}