类org.slf4j.helpers.FormattingTuple源码实例Demo

下面列出了怎么用org.slf4j.helpers.FormattingTuple的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: slf4android   文件: MessageValueSupplier.java
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
@Override
public void append(LogRecord record, StringBuilder builder) {
    FormattingTuple formattingTuple = MessageFormatter.arrayFormat(record.getMessage(), record.getParameters());
    String message = formattingTuple.getMessage();
    Throwable throwable = formattingTuple.getThrowable();
    if (throwable != null) {
        StringWriter writer = new StringWriter(100);
        PrintWriter printWriter = new PrintWriter(writer);
        throwable.printStackTrace(printWriter);
        printWriter.flush();
        printWriter.close();
        writer.flush();
        message += " " + writer.toString();
    }
    builder.append(message);
}
 
源代码2 项目: HttpSessionReplacer   文件: JDK14LoggerAdapter.java
private LogRecord eventToRecord(LoggingEvent event, Level julLevel) {
    String format = event.getMessage();
    Object[] arguments = event.getArgumentArray();
    FormattingTuple ft = MessageFormatter.arrayFormat(format, arguments);
    if (ft.getThrowable() != null && event.getThrowable() != null) {
        throw new IllegalArgumentException("both last element in argument array and last argument are of type Throwable");
    }

    Throwable t = event.getThrowable();
    if (ft.getThrowable() != null) {
        t = ft.getThrowable();
        throw new IllegalStateException("fix above code");
    }

    LogRecord record = new LogRecord(julLevel, ft.getMessage());
    record.setLoggerName(event.getLoggerName());
    record.setMillis(event.getTimeStamp());
    record.setSourceClassName(EventConstants.NA_SUBST);
    record.setSourceMethodName(EventConstants.NA_SUBST);

    record.setThrown(t);
    return record;
}
 
源代码3 项目: xxl-job   文件: XxlJobLogger.java
/**
 * 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);
}
 
源代码4 项目: microservices-platform   文件: XxlJobLogger.java
/**
 * 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);
}
 
源代码5 项目: zuihou-admin-boot   文件: XxlJobLogger.java
/**
 * 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);
}
 
源代码6 项目: velocity-engine   文件: EventExample.java
/**
 * This prints the level and formatted message to
 * System.out.
 */
public void formatAndLog(int level, String format, Object... arguments)
{
    if (logOutput)
    {
        FormattingTuple tp = MessageFormatter.arrayFormat(format, arguments);
        log(level, tp.getMessage());
    }
}
 
源代码7 项目: PeonyFramwork   文件: LocalizationMessage.java
public static String getText(String key,Object... args){
    String localization = threadLocalization.get();
    if(localization == null){
        log.warn("localization is not in threadLocalization,check it !");
        localization = DefaultLocalization;
    }
    Properties properties = messages.get(localization);
    if(properties == null){
        properties = messages.get(DefaultLocalization);
    }
    FormattingTuple formattingTuple = MessageFormatter.arrayFormat(properties.getProperty(key),args);
    return formattingTuple.getMessage();
}
 
源代码8 项目: xmfcn-spring-cloud   文件: XxlJobLogger.java
/**
 * 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);
}
 
源代码9 项目: deadcode4j   文件: LoggerForMavenLog.java
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
private void doWarn(FormattingTuple tuple) {
    if (tuple.getThrowable() == null) {
        log.warn(tuple.getMessage());
    } else {
        log.warn(tuple.getMessage(), tuple.getThrowable());
    }
}
 
源代码10 项目: zuihou-admin-cloud   文件: XxlJobLogger.java
/**
 * 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);
}
 
源代码11 项目: eclair   文件: JavaLoggerFacade.java
@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);
}
 
源代码12 项目: JDA   文件: SimpleLogger.java
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());
}
 
源代码13 项目: snowflake-jdbc   文件: SLF4JLogger.java
public void info(String msg, Object... arguments)
{
  if (isInfoEnabled())
  {
    FormattingTuple ft = MessageFormatter.arrayFormat(
        msg, evaluateLambdaArgs(arguments));
    this.info(SecretDetector.maskSecrets(ft.getMessage()));
  }
}
 
源代码14 项目: jboot   文件: Slf4jSimpleLogger.java
@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);
    }
}
 
源代码15 项目: jboot   文件: Slf4jLogger.java
@Override
public void trace(String format, Object... args) {
    if (isTraceEnabled()) {
        FormattingTuple ft = MessageFormatter.arrayFormat(format, args);
        log.log(null, callerFQCN, LocationAwareLogger.TRACE_INT, ft.getMessage(), NULL_ARGS, ft.getThrowable());
    }
}
 
源代码16 项目: jboot   文件: Slf4jLogger.java
@Override
public void debug(String format, Object... args) {
    if (isDebugEnabled()) {
        FormattingTuple ft = MessageFormatter.arrayFormat(format, args);
        log.log(null, callerFQCN, LocationAwareLogger.DEBUG_INT, ft.getMessage(), NULL_ARGS, ft.getThrowable());
    }
}
 
源代码17 项目: jboot   文件: Slf4jLogger.java
@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());
    }
}
 
源代码18 项目: jboot   文件: Slf4jLogger.java
@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());
    }
}
 
源代码19 项目: karate   文件: Logger.java
private void formatAndAppend(String format, Object... arguments) {
    if (appender == null) {
        return;
    }
    FormattingTuple tp = MessageFormatter.arrayFormat(format, arguments);
    append(tp.getMessage());
}
 
源代码20 项目: snowflake-jdbc   文件: SLF4JLogger.java
public void error(String msg, Object... arguments)
{
  if (isErrorEnabled())
  {
    FormattingTuple ft = MessageFormatter.arrayFormat(
        msg, evaluateLambdaArgs(arguments));
    this.error(SecretDetector.maskSecrets(ft.getMessage()));
  }
}
 
源代码21 项目: xltsearch   文件: MessageLogger.java
private void add(Message.Level level, FormattingTuple tp) {
    if (tp.getThrowable() == null) {
        add(level, tp.getMessage());
    } else {
        add(level, tp.getMessage(), tp.getThrowable());
    }
}
 
源代码22 项目: snowflake-jdbc   文件: SLF4JLogger.java
public void warn(String msg, Object... arguments)
{
  if (isWarnEnabled())
  {
    FormattingTuple ft = MessageFormatter.arrayFormat(
        msg, evaluateLambdaArgs(arguments));
    this.warn(SecretDetector.maskSecrets(ft.getMessage()));
  }
}
 
源代码23 项目: LogFX   文件: LogFXLogger.java
private void formatAndLog( LogLevel logLevel, String format, Object... arguments ) {
    if ( !LogFXLogFactory.INSTANCE.isLogLevelEnabled( logLevel ) ) {
        return;
    }

    FormattingTuple tp = MessageFormatter.arrayFormat( format, arguments );
    log( logLevel, tp.getMessage(), tp.getThrowable() );
}
 
源代码24 项目: 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());
}
 
源代码25 项目: common-utils   文件: DefaultLogger.java
@Override
public void error(String msg, Throwable t, Object...arguments) {
    FormattingTuple ft = MessageFormatter.arrayFormat(msg, arguments);

    logger.error(ft.getMessage(), ft.getThrowable());
}
 
源代码26 项目: kylin-on-parquet-v2   文件: BufferedLogger.java
@Override
public void log(String message, Object... arguments) {
    FormattingTuple ft = MessageFormatter.arrayFormat(message, arguments);
    log(ft.getMessage());
}
 
@Test
public void messageFormatterTest()
{
    FormattingTuple tuple = MessageFormatter.format( "this is a test {} and {}", "test", "foobar" );
    assertEquals( "this is a test test and foobar", tuple.getMessage() );
}
 
源代码28 项目: openzaly   文件: LogUtils.java
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());
}
 
源代码29 项目: velocity-engine   文件: TestLogger.java
public void warn(String format, Object[] argArray)
{
    FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray);
    log(LOG_LEVEL_WARN, ft.getMessage(), ft.getThrowable());
}
 
源代码30 项目: Bukkit-SSHD   文件: PluginSlf4jFactory.java
private void log(Level level, String s, Object[] objects) {
   if (SshdPlugin.instance != null && isEnabled(level)) {
       FormattingTuple ft = MessageFormatter.arrayFormat(s, objects);
       SshdPlugin.instance.getLogger().log(level, ft.getMessage(), ft.getThrowable());
   }
}