@Test public void testInsufficientArgsLogsOriginalExceptionForWarn() { Throwable exception = new Throwable("foo"); String format = "some message: %s, %d"; String param = "blah"; logger.warn(exception, format, param); assertLogLike(Level.SEVERE, ImmutableList.of("Invalid format", "WARN", format, param), IllegalArgumentException.class); assertLog(Level.WARNING, String.format("'%s' [%s]", format, param), exception); }
public void warn(Throwable exception, String format, Object... args) { if (logger.isLoggable(WARNING)) { String message; try { message = format(format, args); } catch (IllegalFormatException e) { logger.log(SEVERE, illegalFormatMessageFor(Level.WARN, format, args), e); message = rawMessageFor(format, args); } logger.log(WARNING, message, exception); } }
Logger { public void warn(Throwable exception, String format, Object... args) { if (logger.isLoggable(WARNING)) { String message; try { message = format(format, args); } catch (IllegalFormatException e) { logger.log(SEVERE, illegalFormatMessageFor(Level.WARN, format, args), e); message = rawMessageFor(format, args); } logger.log(WARNING, message, exception); } } }
Logger { public void warn(Throwable exception, String format, Object... args) { if (logger.isLoggable(WARNING)) { String message; try { message = format(format, args); } catch (IllegalFormatException e) { logger.log(SEVERE, illegalFormatMessageFor(Level.WARN, format, args), e); message = rawMessageFor(format, args); } logger.log(WARNING, message, exception); } } Logger(java.util.logging.Logger logger); }
Logger { public void warn(Throwable exception, String format, Object... args) { if (logger.isLoggable(WARNING)) { String message; try { message = format(format, args); } catch (IllegalFormatException e) { logger.log(SEVERE, illegalFormatMessageFor(Level.WARN, format, args), e); message = rawMessageFor(format, args); } logger.log(WARNING, message, exception); } } Logger(java.util.logging.Logger logger); static Logger get(Class<?> clazz); static Logger get(String name); void trace(String format, Object... args); void debug(String format, Object... args); void debug(Throwable exception, String format, Object... args); void info(String format, Object... args); void warn(Throwable exception, String format, Object... args); void warn(String format, Object... args); void error(Throwable exception, String format, Object... args); void error(Throwable exception); void error(String format, Object... args); boolean isDebugEnabled(); boolean isInfoEnabled(); }
Logger { public void warn(Throwable exception, String format, Object... args) { if (logger.isLoggable(WARNING)) { String message; try { message = format(format, args); } catch (IllegalFormatException e) { logger.log(SEVERE, illegalFormatMessageFor(Level.WARN, format, args), e); message = rawMessageFor(format, args); } logger.log(WARNING, message, exception); } } Logger(java.util.logging.Logger logger); static Logger get(Class<?> clazz); static Logger get(String name); void trace(String format, Object... args); void debug(String format, Object... args); void debug(Throwable exception, String format, Object... args); void info(String format, Object... args); void warn(Throwable exception, String format, Object... args); void warn(String format, Object... args); void error(Throwable exception, String format, Object... args); void error(Throwable exception); void error(String format, Object... args); boolean isDebugEnabled(); boolean isInfoEnabled();  }