當前位置: 首頁>>代碼示例>>Java>>正文


Java FormattingTuple類代碼示例

本文整理匯總了Java中org.slf4j.helpers.FormattingTuple的典型用法代碼示例。如果您正苦於以下問題:Java FormattingTuple類的具體用法?Java FormattingTuple怎麽用?Java FormattingTuple使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FormattingTuple類屬於org.slf4j.helpers包,在下文中一共展示了FormattingTuple類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: eventToRecord

import org.slf4j.helpers.FormattingTuple; //導入依賴的package包/類
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;
}
 
開發者ID:AmadeusITGroup,項目名稱:HttpSessionReplacer,代碼行數:24,代碼來源:JDK14LoggerAdapter.java

示例2: log

import org.slf4j.helpers.FormattingTuple; //導入依賴的package包/類
public void log(String messageId, Object[] args, boolean status, UUID housingUnitId, UUID projectId,
		UUID clientId) {
	FormattingTuple tp = null;

	try {
		tp = MessageFormatter.arrayFormat(env.getProperty(messageId), args);
		System.out.println("  Message "+messageId+" test message "+tp.getMessage()+" test");
		if(env.getProperty(messageId).isEmpty()) System.out.println("Empty property");
	} catch (Exception e) {
		System.out.println("Exception message property "+messageId);
		tp = MessageFormatter.arrayFormat("Message foormat tewst {} with tuple {}", new Object[] { "param1" });
	}

	MatchProcessLogEntity entity = new MatchProcessLogEntity();
	entity.setClientId(clientId);
	entity.setHousingUnitId(housingUnitId);
	entity.setProjectId(projectId);
	entity.setStatus(status);
	entity.setStatusMessage(tp.getMessage());
	entity.setProcessId(this.processId);
	logRepository.save(entity);
}
 
開發者ID:hserv,項目名稱:coordinated-entry,代碼行數:23,代碼來源:MatchProcessLogger.java

示例3: log

import org.slf4j.helpers.FormattingTuple; //導入依賴的package包/類
public void log(String messageId, Object[] args, boolean status, UUID housingUnitId, UUID projectId,
		UUID clientId) {
	FormattingTuple tp = null;

	try {
		tp = MessageFormatter.arrayFormat(env.getProperty(messageId), args);

	} catch (Exception e) {
		tp = MessageFormatter.arrayFormat("Message foormat tewst {} with tuple {}", new Object[] { "param1" });
	}

	MatchProcessLogEntity entity = new MatchProcessLogEntity();
	entity.setClientId(clientId);
	entity.setHousingUnitId(housingUnitId);
	entity.setProjectId(projectId);
	entity.setStatus(status);
	entity.setStatusMessage(tp.getMessage());
	entity.setProcessId(this.processId);
	logRepository.save(entity);
}
 
開發者ID:hserv,項目名稱:coordinated-entry,代碼行數:21,代碼來源:MatchProcessLogServiceImpl.java

示例4: handleMsg

import org.slf4j.helpers.FormattingTuple; //導入依賴的package包/類
private static void handleMsg(@Nonnull EtcLogEvent event, @Nonnull StringBuilder sb) {
	Object[] args = event.getArgs();
	if(args != null && args.length > 0) {
		FormattingTuple tuple;
		if(args.length == 1) {
			tuple = MessageFormatter.format(event.getMsg(), args);
		} else if(args.length == 2) {
			tuple = org.slf4j.helpers.MessageFormatter.format(event.getMsg(), args[0], args[1]);
		} else {
			tuple = org.slf4j.helpers.MessageFormatter.arrayFormat(event.getMsg(), args);
		}
		sb.append(tuple.getMessage());
	} else {
		sb.append(event.getMsg());
	}
}
 
開發者ID:fjalvingh,項目名稱:domui,代碼行數:17,代碼來源:EtcLogFormatter.java

示例5: doLog

import org.slf4j.helpers.FormattingTuple; //導入依賴的package包/類
@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());
    }
}
 
開發者ID:kwon37xi,項目名稱:slf4j-lambda,代碼行數:14,代碼來源:LambdaLoggerPlainImpl.java

示例6: doLog

import org.slf4j.helpers.FormattingTuple; //導入依賴的package包/類
private void doLog(Level lvl, FormattingTuple tuple) {
    if (tuple.getThrowable() == null) {
        Utils.log(this.logger, 5, this.name, lvl, "%s", tuple.getMessage());
    } else {
        Utils.log(this.logger, 5, this.name, lvl, "%s: %s", tuple.getMessage(), Utils.toString(tuple.getThrowable()));
    }
}
 
開發者ID:vmware,項目名稱:xenon-utils,代碼行數:8,代碼來源:XenonClassLogger.java

示例7: formatAndLog

import org.slf4j.helpers.FormattingTuple; //導入依賴的package包/類
/**
 * 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());
}
 
開發者ID:Esri,項目名稱:server-extension-java,代碼行數:15,代碼來源:LogAdaptor.java

示例8: singleOrException

import org.slf4j.helpers.FormattingTuple; //導入依賴的package包/類
public static final <T> Single<T> singleOrException(Maybe<T> maybe, int statusCode, String message, Object... args) {
    Single<Boolean> isEmpty = maybe.isEmpty();

    return isEmpty.flatMap((_isEmpty) -> {
        if (_isEmpty) {
            FormattingTuple formattedMessage = MessageFormatter.arrayFormat(message, args);

            throw new ServiceException(statusCode, formattedMessage.getMessage());
        }

        return maybe.toSingle();
    });
}
 
開發者ID:Atypon-OpenSource,項目名稱:wayf-cloud,代碼行數:14,代碼來源:FacadePolicies.java

示例9: trace

import org.slf4j.helpers.FormattingTuple; //導入依賴的package包/類
@Override
public void trace(final String format, final Object arg) {
    final FormattingTuple ft = MessageFormatter.format(format, arg);
    Crashlytics.log(Log.VERBOSE, mTag, ft.getMessage());
    if (ft.getThrowable() != null) {
        exception(Log.VERBOSE, ft.getThrowable());
    }
}
 
開發者ID:dasfoo,項目名稱:delern,代碼行數:9,代碼來源:Logger.java

示例10: debug

import org.slf4j.helpers.FormattingTuple; //導入依賴的package包/類
@Override
public void debug(final String format, final Object arg) {
    final FormattingTuple ft = MessageFormatter.format(format, arg);
    Crashlytics.log(Log.DEBUG, mTag, ft.getMessage());
    if (ft.getThrowable() != null) {
        exception(Log.DEBUG, ft.getThrowable());
    }
}
 
開發者ID:dasfoo,項目名稱:delern,代碼行數:9,代碼來源:Logger.java

示例11: info

import org.slf4j.helpers.FormattingTuple; //導入依賴的package包/類
@Override
public void info(final String format, final Object arg) {
    final FormattingTuple ft = MessageFormatter.format(format, arg);
    Crashlytics.log(Log.INFO, mTag, ft.getMessage());
    if (ft.getThrowable() != null) {
        exception(Log.INFO, ft.getThrowable());
    }
}
 
開發者ID:dasfoo,項目名稱:delern,代碼行數:9,代碼來源:Logger.java

示例12: warn

import org.slf4j.helpers.FormattingTuple; //導入依賴的package包/類
@Override
public void warn(final String format, final Object arg) {
    final FormattingTuple ft = MessageFormatter.format(format, arg);
    Crashlytics.log(Log.WARN, mTag, ft.getMessage());
    if (ft.getThrowable() != null) {
        exception(Log.WARN, ft.getThrowable());
    }
}
 
開發者ID:dasfoo,項目名稱:delern,代碼行數:9,代碼來源:Logger.java

示例13: error

import org.slf4j.helpers.FormattingTuple; //導入依賴的package包/類
@Override
public void error(final String format, final Object arg) {
    final FormattingTuple ft = MessageFormatter.format(format, arg);
    Crashlytics.log(Log.ERROR, mTag, ft.getMessage());
    if (ft.getThrowable() != null) {
        exception(Log.ERROR, ft.getThrowable());
    }
}
 
開發者ID:dasfoo,項目名稱:delern,代碼行數:9,代碼來源:Logger.java

示例14: trace

import org.slf4j.helpers.FormattingTuple; //導入依賴的package包/類
/**
 * Log a message at level TRACE according to the specified format and argument.
 * This form avoids superfluous object creation when the logger is disabled for level TRACE.
 *
 * @param format the format string
 * @param arg    the argument
 */
public void trace(String format, Object arg) {
    if (isTraceEnabled()) {
        FormattingTuple ft = MessageFormatter.format(format, arg);
        logger.log(getCallerClassName(), traceCapable ? Level.TRACE : Level.DEBUG,
                ft.getMessage(), ft.getThrowable());
    }
}
 
開發者ID:wings27,項目名稱:easy-logger,代碼行數:15,代碼來源:EasyLog4jLogger.java

示例15: info

import org.slf4j.helpers.FormattingTuple; //導入依賴的package包/類
/**
 * Log a message at level INFO according to the specified format and argument.
 * This form avoids superfluous object creation when the logger is disabled for the INFO level.
 *
 * @param format the format string
 * @param arg    the argument
 */
public void info(String format, Object arg) {
    if (logger.isInfoEnabled()) {
        FormattingTuple ft = MessageFormatter.format(format, arg);
        logger.log(getCallerClassName(), Level.INFO, ft.getMessage(),
                ft.getThrowable());
    }
}
 
開發者ID:wings27,項目名稱:easy-logger,代碼行數:15,代碼來源:EasyLog4jLogger.java


注:本文中的org.slf4j.helpers.FormattingTuple類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。