Refine search
/** * 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 arguments an array of arguments */ public void debug(String format, Object... arguments) { if (logger.isDebugEnabled()) { FormattingTuple ft = MessageFormatter.arrayFormat(format, arguments); logger.log(FQCN, Level.DEBUG, ft.getMessage(), ft.getThrowable()); } }
/** * 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 */ 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()); } }
safeObjectAppend(sbuf, o); } else { booleanArrayAppend(sbuf, (boolean[]) o); } else if (o instanceof byte[]) { byteArrayAppend(sbuf, (byte[]) o); } else if (o instanceof char[]) { charArrayAppend(sbuf, (char[]) o); } else if (o instanceof short[]) { shortArrayAppend(sbuf, (short[]) o); } else if (o instanceof int[]) { intArrayAppend(sbuf, (int[]) o); } else if (o instanceof long[]) { longArrayAppend(sbuf, (long[]) o); } else if (o instanceof float[]) { floatArrayAppend(sbuf, (float[]) o); } else if (o instanceof double[]) { doubleArrayAppend(sbuf, (double[]) o); } else { objectArrayAppend(sbuf, (Object[]) o, seenMap);
final public static FormattingTuple arrayFormat(final String messagePattern, final Object[] argArray) { Throwable throwableCandidate = getThrowableCandidate(argArray); Object[] args = argArray; if (throwableCandidate != null) { args = trimmedCopy(argArray); } return arrayFormat(messagePattern, args, throwableCandidate); }
public String getFormattedMessage() { if (formattedMessage != null) { return formattedMessage; } if (argumentArray != null) { formattedMessage = MessageFormatter.arrayFormat(message, argumentArray).getMessage(); } else { formattedMessage = message; } return formattedMessage; }
@Override public void doLog(int level, String message, Object[] params, Throwable t) { String formattedMessage = fullMessage(message); if (params != null && params.length > 0) { formattedMessage = MessageFormatter.arrayFormat(formattedMessage, params).getMessage(); } log.log(null, fqcn, level, formattedMessage, null, t); } }
/** * Delegate to the appropriate method of the underlying logger. */ public void info(String format, Object arg) { if (!logger.isInfoEnabled()) return; if (instanceofLAL) { String formattedMessage = MessageFormatter.format(format, arg).getMessage(); ((LocationAwareLogger) logger).log(null, fqcn, LocationAwareLogger.INFO_INT, formattedMessage, new Object[] { arg }, null); } else { logger.info(format, arg); } }
private void writeLog(Marker marker, int level, String format, Object[] args, Throwable exception) { String message = format; if (args != null && args.length > 0) { FormattingTuple formatted = MessageFormatter.arrayFormat(format, args); if (exception == null && formatted.getThrowable() != null) { exception = formatted.getThrowable(); } message = formatted.getMessage(); } logger.log(marker, fqcn, level, addPrefix(message), null, exception); } }
private void log(Marker marker, int level, String msg, Object[] argArray, Throwable t) { if (argArray == null) { // Simple SLF4J Message (no args) _logger.log(marker, FQCN, level, msg, null, t); } else { int loggerLevel = _logger.isTraceEnabled() ? TRACE : _logger.isDebugEnabled() ? DEBUG : _logger.isInfoEnabled() ? INFO : _logger.isWarnEnabled() ? WARN : ERROR; if (loggerLevel <= level) { // Don't assume downstream handles argArray properly. // Do it the SLF4J way here to eliminate that as a bug. FormattingTuple ft = MessageFormatter.arrayFormat(msg, argArray); _logger.log(marker, FQCN, level, ft.getMessage(), null, t); } } } }
/** * 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()); }
/** * 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()); }
/** * Log method exit * * @param result * The result of the method being exited */ public <T> T exit(T result) { if (instanceofLAL && logger.isTraceEnabled(ENTRY_MARKER)) { FormattingTuple tp = MessageFormatter.format(EXIT_MESSAGE_1, result); ((LocationAwareLogger) logger).log(EXIT_MARKER, FQCN, LocationAwareLogger.TRACE_INT, tp.getMessage(), new Object[] { result }, tp.getThrowable()); } return result; }
@Override public void trace(String format, Object... argArray) { if (isTraceEnabled()) { log(TRACE_INT, org.slf4j.helpers.MessageFormatter.format(format, argArray)); } }
private void testXKindGenericDefinitionSuccess(Class<?> type) { Object p = createProxy(type); try { executeCommand(p); HystrixInvokableInfo<?> command = getHystrixCommandByKey("command"); assertTrue(command.getExecutionEvents().contains(HystrixEventType.FAILURE)); assertTrue(command.getExecutionEvents().contains(HystrixEventType.FALLBACK_SUCCESS)); } catch (FallbackDefinitionException e) { throw new AssertionError(MessageFormatter.format("Case class '{}' has failed. Reason:\n{}", type.getCanonicalName(), e).getMessage()); } }
/** * Performs single argument substitution for the 'messagePattern' passed as * parameter. * <p> * For example, * * <pre> * MessageFormatter.format("Hi {}.", "there"); * </pre> * * will return the string "Hi there.". * <p> * * @param messagePattern * The message pattern which will be parsed and formatted * @param arg * The argument to be substituted in place of the formatting anchor * @return The formatted message */ final public static FormattingTuple format(String messagePattern, Object arg) { return arrayFormat(messagePattern, new Object[] { arg }); }
public String getFormattedMessage() { if (formattedMessage != null) { return formattedMessage; } if (argumentArray != null) { formattedMessage = MessageFormatter.arrayFormat(message, argumentArray).getMessage(); } else { formattedMessage = message; } return formattedMessage; }
@Override public void doLog(int level, String message, Object[] params, Throwable t) { String formattedMessage = fullMessage(message); if (params != null && params.length > 0) { formattedMessage = MessageFormatter.arrayFormat(formattedMessage, params).getMessage(); } log.log(null, fqcn, level, formattedMessage, null, t); } }
/** * Delegate to the appropriate method of the underlying logger. */ public void trace(String format, Object arg) { if (!logger.isTraceEnabled()) return; if (instanceofLAL) { String formattedMessage = MessageFormatter.format(format, arg).getMessage(); ((LocationAwareLogger) logger).log(null, fqcn, LocationAwareLogger.TRACE_INT, formattedMessage, new Object[] { arg }, null); } else { logger.trace(format, arg); } }
level == ERROR_INT && logger.isErrorEnabled()) { LocationAwareLogger l = (LocationAwareLogger) logger; FormattingTuple ft = MessageFormatter.arrayFormat(msg, parameters); l.log(null, FQCN, level, ft.getMessage(), null, ft.getThrowable());
private org.apache.log4j.spi.LoggingEvent toLog4jEvent(LoggingEvent event, Level log4jLevel) { FormattingTuple ft = MessageFormatter.format(event.getMessage(), event.getArgumentArray(), event.getThrowable()); LocationInfo locationInfo = new LocationInfo(NA_SUBST, NA_SUBST, NA_SUBST, "0"); ThrowableInformation ti = null; Throwable t = ft.getThrowable(); if (t != null) ti = new ThrowableInformation(t); org.apache.log4j.spi.LoggingEvent log4jEvent = new org.apache.log4j.spi.LoggingEvent(FQCN, logger, event.getTimeStamp(), log4jLevel, ft.getMessage(), event.getThreadName(), ti, null, locationInfo, null); return log4jEvent; }