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

The following examples show how to use org.slf4j.helpers.MessageFormatter#arrayFormat() . 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: LambdaLoggerPlainImpl.java    From slf4j-lambda with Apache License 2.0 5 votes vote down vote up
@Override
public void doLog(Marker marker, Level level, String format, Supplier<?>[] argSuppliers, Throwable t) {
    if (!LambdaLoggerUtils.isLogLevelEnabled(underlyingLogger, level, marker)) {
        return;
    }

    if (argSuppliers == null) {
        logFormatted(marker, level, format, t);
    } else {
        FormattingTuple formattingTuple = MessageFormatter.arrayFormat(format, argSuppliersToArgs(argSuppliers), t);
        logFormatted(marker, level, formattingTuple.getMessage(), formattingTuple.getThrowable());
    }
}
 
Example 2
Source File: JavaLoggerFacade.java    From eclair with Apache License 2.0 5 votes vote down vote up
@Override
public void log(LogLevel level, String format, Object... arguments) {
    FormattingTuple formattingTuple = MessageFormatter.arrayFormat(format, arguments);
    String message = formattingTuple.getMessage();
    Throwable throwable = formattingTuple.getThrowable();
    logger.log(LEVELS.get(level), message, throwable);
}
 
Example 3
Source File: SLF4JLogger.java    From snowflake-jdbc with Apache License 2.0 5 votes vote down vote up
public void trace(String msg, Object... arguments)
{
  if (isTraceEnabled())
  {
    FormattingTuple ft = MessageFormatter.arrayFormat(
        msg, evaluateLambdaArgs(arguments));
    this.trace(SecretDetector.maskSecrets(ft.getMessage()));
  }
}
 
Example 4
Source File: Slf4jLogger.java    From jboot with Apache License 2.0 5 votes vote down vote up
@Override
public void warn(String format, Object... args) {
    if (isWarnEnabled()) {
        FormattingTuple ft = MessageFormatter.arrayFormat(format, args);
        log.log(null, callerFQCN, LocationAwareLogger.WARN_INT, ft.getMessage(), NULL_ARGS, ft.getThrowable());
    }
}
 
Example 5
Source File: SLF4JLogger.java    From snowflake-jdbc with Apache License 2.0 5 votes vote down vote up
public void debug(String msg, Object... arguments)
{
  // use this as format example for JDK14Logger.
  if (isDebugEnabled())
  {
    FormattingTuple ft = MessageFormatter.arrayFormat(
        msg, evaluateLambdaArgs(arguments));
    this.debug(SecretDetector.maskSecrets(ft.getMessage()));
  }
}
 
Example 6
Source File: Slf4jLogger.java    From jboot with Apache License 2.0 5 votes vote down vote up
@Override
public void info(String format, Object... args) {
    if (isInfoEnabled()) {
        FormattingTuple ft = MessageFormatter.arrayFormat(format, args);
        log.log(null, callerFQCN, LocationAwareLogger.INFO_INT, ft.getMessage(), NULL_ARGS, ft.getThrowable());
    }
}
 
Example 7
Source File: Slf4jLogger.java    From jboot with Apache License 2.0 5 votes vote down vote up
@Override
public void error(String format, Object... args) {
    if (isErrorEnabled()) {
        FormattingTuple ft = MessageFormatter.arrayFormat(format, args);
        JbootExceptionHolder.hold(ft.getMessage(), ft.getThrowable());
        log.log(null, callerFQCN, LocationAwareLogger.ERROR_INT, ft.getMessage(), NULL_ARGS, ft.getThrowable());
    }
}
 
Example 8
Source File: SLF4JLogger.java    From snowflake-jdbc with Apache License 2.0 5 votes vote down vote up
public void error(String msg, Object... arguments)
{
  if (isErrorEnabled())
  {
    FormattingTuple ft = MessageFormatter.arrayFormat(
        msg, evaluateLambdaArgs(arguments));
    this.error(SecretDetector.maskSecrets(ft.getMessage()));
  }
}
 
Example 9
Source File: XxlJobLogger.java    From zuihou-admin-boot with Apache License 2.0 5 votes vote down vote up
/**
 * append log with pattern
 *
 * @param appendLogPattern   like "aaa {} bbb {} ccc"
 * @param appendLogArguments like "111, true"
 */
public static void log(String appendLogPattern, Object... appendLogArguments) {

    FormattingTuple ft = MessageFormatter.arrayFormat(appendLogPattern, appendLogArguments);
    String appendLog = ft.getMessage();

    /*appendLog = appendLogPattern;
    if (appendLogArguments!=null && appendLogArguments.length>0) {
        appendLog = MessageFormat.format(appendLogPattern, appendLogArguments);
    }*/

    StackTraceElement callInfo = new Throwable().getStackTrace()[1];
    logDetail(callInfo, appendLog);
}
 
Example 10
Source File: Slf4jSimpleLogger.java    From jboot with Apache License 2.0 5 votes vote down vote up
@Override
public void error(String format, Object... args) {
    if (isErrorEnabled()) {
        FormattingTuple ft = MessageFormatter.arrayFormat(format, args);
        JbootExceptionHolder.hold(ft.getMessage(), ft.getThrowable());
        log.error(format, args);
    }
}
 
Example 11
Source File: JobLogger.java    From datax-web with MIT License 5 votes vote down vote up
/**
 * append log with pattern
 *
 * @param appendLogPattern   like "aaa {} bbb {} ccc"
 * @param appendLogArguments like "111, true"
 */
public static void log(String appendLogPattern, Object... appendLogArguments) {

    FormattingTuple ft = MessageFormatter.arrayFormat(appendLogPattern, appendLogArguments);
    String appendLog = ft.getMessage();

    /*appendLog = appendLogPattern;
    if (appendLogArguments!=null && appendLogArguments.length>0) {
        appendLog = MessageFormat.format(appendLogPattern, appendLogArguments);
    }*/

    StackTraceElement callInfo = new Throwable().getStackTrace()[1];
    logDetail(callInfo, appendLog);
}
 
Example 12
Source File: LogUtils.java    From openzaly with Apache License 2.0 4 votes vote down vote up
public static void dbDebugLog(Logger logger, long startTime, Object result, String sql, Object... objects) {
	String messagePattern = sql.replace("?", "{}");
	FormattingTuple format = MessageFormatter.arrayFormat(messagePattern, objects);
	logger.debug("[openzaly-db] cost:{}ms result:{} sql:{}", System.currentTimeMillis() - startTime, result,
			format.getMessage());
}
 
Example 13
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... objects) {
	FormattingTuple format = MessageFormatter.arrayFormat(messagePattern, objects);
	logger.info(format.getMessage());
}
 
Example 14
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
 * arguments.
 *
 * <p>
 * This form avoids superfluous object creation when the logger is disabled
 * for the INFO level.
 * </p>
 *
 * @param format
 *          the format string
 * @param argArray
 *          an array of arguments
 */
@Override
public void info(String format, Object... argArray) {
    if (logger.isInfoEnabled()) {
        FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray);
        logger.log(FQCN, Level.INFO, ft.getMessage(), ft.getThrowable());
    }
}
 
Example 15
Source File: Log4jLoggerAdapter.java    From HttpSessionReplacer with MIT License 3 votes vote down vote up
/**
 * Log a message at level WARN 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 argArray
 *          an array of arguments
 */
@Override
public void warn(String format, Object... argArray) {
    if (logger.isEnabledFor(Level.WARN)) {
        FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray);
        logger.log(FQCN, Level.WARN, ft.getMessage(), ft.getThrowable());
    }
}
 
Example 16
Source File: JDK14LoggerAdapter.java    From HttpSessionReplacer with MIT License 3 votes vote down vote up
/**
 * Log a message at level SEVERE according to the specified format and
 * arguments.
 *
 * <p>
 * This form avoids superfluous object creation when the logger is disabled
 * for the SEVERE level.
 * </p>
 *
 * @param format
 *          the format string
 * @param arguments
 *          an array of arguments
 */
@Override
public void error(String format, Object... arguments) {
    if (logger.isLoggable(Level.SEVERE)) {
        FormattingTuple ft = MessageFormatter.arrayFormat(format, arguments);
        log(SELF, Level.SEVERE, 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#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 arguments a list of 3 or more arguments
 */
@Override
public void debug(String format, Object... arguments) {
    if (log.isDebugEnabled()) {
        FormattingTuple ft = MessageFormatter.arrayFormat(format, arguments);
        log.debug(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#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 arguments a list of 3 or more arguments
 */
@Override
public void info(String format, Object... arguments) {
    if (log.isInfoEnabled()) {
        FormattingTuple ft = MessageFormatter.arrayFormat(format, arguments);
        log.info(ft.getMessage(), ft.getThrowable());
    }
}
 
Example 19
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 arguments a list of 3 or more arguments
 */
@Override
public void trace(String format, Object... arguments) {
    if (log.isTraceEnabled()) {
        FormattingTuple ft = MessageFormatter.arrayFormat(format, arguments);
        log.trace(ft.getMessage(), ft.getThrowable());
    }
}
 
Example 20
Source File: JDK14LoggerAdapter.java    From HttpSessionReplacer with MIT License 3 votes vote down vote up
/**
 * Log a message at level WARNING according to the specified format and
 * arguments.
 *
 * <p>
 * This form avoids superfluous object creation when the logger is disabled
 * for the WARNING level.
 * </p>
 *
 * @param format
 *          the format string
 * @param argArray
 *          an array of arguments
 */
@Override
public void warn(String format, Object... argArray) {
    if (logger.isLoggable(Level.WARNING)) {
        FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray);
        log(SELF, Level.WARNING, ft.getMessage(), ft.getThrowable());
    }
}