Java 类org.slf4j.helpers.FormattingTuple 实例源码
项目: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;
}
项目:coordinated-entry
文件:MatchProcessLogger.java
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);
}
项目:coordinated-entry
文件:MatchProcessLogServiceImpl.java
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);
}
项目:domui
文件:EtcLogFormatter.java
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());
}
}
项目:slf4j-lambda
文件:LambdaLoggerPlainImpl.java
@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());
}
}
项目:slf4j-lambda
文件:LambdaLoggerPlainImpl.java
@Override
public void doLog(Marker marker, Level level, String format, Object[] arguments, Throwable t) {
if (!LambdaLoggerUtils.isLogLevelEnabled(underlyingLogger, level, marker)) {
return;
}
if (arguments == null) {
logFormatted(marker, level, format, t);
} else {
FormattingTuple formattingTuple = MessageFormatter.arrayFormat(format, arguments, t);
logFormatted(marker, level, formattingTuple.getMessage(), formattingTuple.getThrowable());
}
}
项目:xenon-utils
文件:XenonClassLogger.java
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()));
}
}
项目:server-extension-java
文件:LogAdaptor.java
/**
* 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());
}
项目:wayf-cloud
文件:FacadePolicies.java
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();
});
}
项目:wayf-cloud
文件:FacadePolicies.java
public static final <T> Single<T> singleOrException(Observable<T> observable, int statusCode, String message, Object... args) {
Single<Long> count = observable.count();
return count.flatMap((_count) -> {
if (_count != 1) {
FormattingTuple formattedMessage = MessageFormatter.arrayFormat(message, args);
throw new ServiceException(statusCode, formattedMessage.getMessage());
}
return observable.singleOrError();
});
}
项目:delern
文件:Logger.java
@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());
}
}
项目:delern
文件:Logger.java
@Override
public void trace(final String format, final Object arg1, final Object arg2) {
final FormattingTuple ft = MessageFormatter.format(format, arg1, arg2);
Crashlytics.log(Log.VERBOSE, mTag, ft.getMessage());
if (ft.getThrowable() != null) {
Crashlytics.logException(ft.getThrowable());
exception(Log.VERBOSE, ft.getThrowable());
}
}
项目:delern
文件:Logger.java
@Override
public void trace(final String format, final Object... arguments) {
final FormattingTuple ft = MessageFormatter.arrayFormat(format, arguments);
Crashlytics.log(Log.VERBOSE, mTag, ft.getMessage());
if (ft.getThrowable() != null) {
exception(Log.VERBOSE, ft.getThrowable());
}
}
项目:delern
文件:Logger.java
@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());
}
}
项目:delern
文件:Logger.java
@Override
public void debug(final String format, final Object arg1, final Object arg2) {
final FormattingTuple ft = MessageFormatter.format(format, arg1, arg2);
Crashlytics.log(Log.DEBUG, mTag, ft.getMessage());
if (ft.getThrowable() != null) {
exception(Log.DEBUG, ft.getThrowable());
}
}
项目:delern
文件:Logger.java
@Override
public void debug(final String format, final Object... arguments) {
final FormattingTuple ft = MessageFormatter.arrayFormat(format, arguments);
Crashlytics.log(Log.DEBUG, mTag, ft.getMessage());
if (ft.getThrowable() != null) {
exception(Log.DEBUG, ft.getThrowable());
}
}
项目:delern
文件:Logger.java
@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());
}
}
项目:delern
文件:Logger.java
@Override
public void info(final String format, final Object arg1, final Object arg2) {
final FormattingTuple ft = MessageFormatter.format(format, arg1, arg2);
Crashlytics.log(Log.INFO, mTag, ft.getMessage());
if (ft.getThrowable() != null) {
exception(Log.INFO, ft.getThrowable());
}
}
项目:delern
文件:Logger.java
@Override
public void info(final String format, final Object... arguments) {
final FormattingTuple ft = MessageFormatter.arrayFormat(format, arguments);
Crashlytics.log(Log.INFO, mTag, ft.getMessage());
if (ft.getThrowable() != null) {
exception(Log.INFO, ft.getThrowable());
}
}
项目:delern
文件:Logger.java
@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());
}
}
项目:delern
文件:Logger.java
@Override
public void warn(final String format, final Object arg1, final Object arg2) {
final FormattingTuple ft = MessageFormatter.format(format, arg1, arg2);
Crashlytics.log(Log.WARN, mTag, ft.getMessage());
if (ft.getThrowable() != null) {
exception(Log.WARN, ft.getThrowable());
}
}
项目:delern
文件:Logger.java
@Override
public void warn(final String format, final Object... arguments) {
final FormattingTuple ft = MessageFormatter.format(format, arguments);
Crashlytics.log(Log.WARN, mTag, ft.getMessage());
if (ft.getThrowable() != null) {
exception(Log.WARN, ft.getThrowable());
}
}
项目:delern
文件:Logger.java
@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());
}
}
项目:delern
文件:Logger.java
@Override
public void error(final String format, final Object arg1, final Object arg2) {
final FormattingTuple ft = MessageFormatter.format(format, arg1, arg2);
Crashlytics.log(Log.ERROR, mTag, ft.getMessage());
if (ft.getThrowable() != null) {
exception(Log.ERROR, ft.getThrowable());
}
}
项目:delern
文件:Logger.java
@Override
public void error(final String format, final Object... arguments) {
final FormattingTuple ft = MessageFormatter.arrayFormat(format, arguments);
Crashlytics.log(Log.ERROR, mTag, ft.getMessage());
if (ft.getThrowable() != null) {
exception(Log.ERROR, ft.getThrowable());
}
}
项目:easy-logger
文件:EasyLog4jLogger.java
/**
* 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());
}
}
项目:easy-logger
文件:EasyLog4jLogger.java
/**
* Log a message at level TRACE according to the specified format and arguments.
* This form avoids superfluous object creation when the logger is disabled for the TRACE level.
*
* @param format the format string
* @param arguments an array of arguments
*/
public void trace(String format, Object... arguments) {
if (isTraceEnabled()) {
FormattingTuple ft = MessageFormatter.arrayFormat(format, arguments);
logger.log(getCallerClassName(), traceCapable ? Level.TRACE : Level.DEBUG, ft
.getMessage(), ft.getThrowable());
}
}
项目:easy-logger
文件:EasyLog4jLogger.java
/**
* 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());
}
}
项目:easy-logger
文件:EasyLog4jLogger.java
/**
* Log a message at level INFO according to the specified format and arguments.
* This form avoids superfluous object creation when the logger is disabled for the INFO level.
*
* @param format the format string
* @param argArray an array of arguments
*/
public void info(String format, Object... argArray) {
if (logger.isInfoEnabled()) {
FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray);
logger.log(getCallerClassName(), Level.INFO, ft.getMessage(),
ft.getThrowable());
}
}
项目:easy-logger
文件:EasyLog4jLogger.java
/**
* Log a message at the WARN level according to the specified format and argument.
* This form avoids superfluous object creation when the logger is disabled for the WARN level.
*
* @param format the format string
* @param arg the argument
*/
public void warn(String format, Object arg) {
if (logger.isEnabledFor(Level.WARN)) {
FormattingTuple ft = MessageFormatter.format(format, arg);
logger.log(getCallerClassName(), Level.WARN, ft.getMessage(),
ft.getThrowable());
}
}
项目:easy-logger
文件:EasyLog4jLogger.java
/**
* Log a message at level WARN according to the specified format and arguments.
* This form avoids superfluous object creation when the logger is disabled for the WARN level.
*
* @param format the format string
* @param argArray an array of arguments
*/
public void warn(String format, Object... argArray) {
if (logger.isEnabledFor(Level.WARN)) {
FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray);
logger.log(getCallerClassName(), Level.WARN, ft.getMessage(),
ft.getThrowable());
}
}
项目:easy-logger
文件:EasyLog4jLogger.java
/**
* Log a message at the ERROR level according to the specified format and argument.
* This form avoids superfluous object creation when the logger is disabled for the ERROR level.
*
* @param format the format string
* @param arg the argument
*/
public void error(String format, Object arg) {
if (logger.isEnabledFor(Level.ERROR)) {
FormattingTuple ft = MessageFormatter.format(format, arg);
logger.log(getCallerClassName(), Level.ERROR, ft.getMessage(),
ft.getThrowable());
}
}
项目:easy-logger
文件:EasyLog4jLogger.java
/**
* Log a message at level ERROR according to the specified format and arguments.
* This form avoids superfluous object creation when the logger is disabled for the ERROR level.
*
* @param format the format string
* @param argArray an array of arguments
*/
public void error(String format, Object... argArray) {
if (logger.isEnabledFor(Level.ERROR)) {
FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray);
logger.log(getCallerClassName(), Level.ERROR, ft.getMessage(),
ft.getThrowable());
}
}
项目:snowflake-jdbc
文件:SLF4JLogger.java
public void debug(String msg, Object... arguments)
{
if (isDebugEnabled())
{
FormattingTuple ft = MessageFormatter.arrayFormat(msg, arguments);
this.debug(ft.getMessage());
}
}
项目:snowflake-jdbc
文件:SLF4JLogger.java
public void error(String msg, Object... arguments)
{
if (isErrorEnabled())
{
FormattingTuple ft = MessageFormatter.arrayFormat(msg, arguments);
this.error(ft.getMessage());
}
}
项目:snowflake-jdbc
文件:SLF4JLogger.java
public void info(String msg, Object... arguments)
{
if (isInfoEnabled())
{
FormattingTuple ft = MessageFormatter.arrayFormat(msg, arguments);
this.info(ft.getMessage());
}
}
项目:snowflake-jdbc
文件:SLF4JLogger.java
public void trace(String msg, Object... arguments)
{
if (isTraceEnabled())
{
FormattingTuple ft = MessageFormatter.arrayFormat(msg, arguments);
this.trace(ft.getMessage());
}
}
项目:snowflake-jdbc
文件:SLF4JLogger.java
public void warn(String msg, Object... arguments)
{
if (isWarnEnabled())
{
FormattingTuple ft = MessageFormatter.arrayFormat(msg, arguments);
this.warn(ft.getMessage());
}
}
项目: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());
}
}
项目:Javacord
文件:JavacordLogger.java
@Override
final public void debug(String format, Object arg1) {
if (isDebugEnabled()) {
FormattingTuple ft = MessageFormatter.format(format, arg1);
LogRecord record = new LogRecord(Level.FINE, ft.getMessage());
record.setThrown(ft.getThrowable());
record.setLoggerName(name);
Logger.getLogger(name).log(record);
}
}