@Test public void testErrorFormat() { logger.error("hello, %s", "you"); assertLog(Level.SEVERE, "hello, you"); @SuppressWarnings("ThrowableInstanceNeverThrown") Throwable exception = new Throwable(); logger.error(exception, "got exception: %s", "foo"); assertLog(Level.SEVERE, "got exception: foo", exception); @SuppressWarnings("ThrowableInstanceNeverThrown") Throwable exception2 = new Throwable("the message"); logger.error(exception2); assertLog(Level.SEVERE, exception2.getMessage(), exception2); }
public void error(Throwable exception, String format, Object... args) { if (logger.isLoggable(SEVERE)) { String message; try { message = format(format, args); } catch (IllegalFormatException e) { logger.log(SEVERE, illegalFormatMessageFor(Level.ERROR, format, args), e); message = rawMessageFor(format, args); } logger.log(SEVERE, message, exception); } }
Logger { public void error(Throwable exception, String format, Object... args) { if (logger.isLoggable(SEVERE)) { String message; try { message = format(format, args); } catch (IllegalFormatException e) { logger.log(SEVERE, illegalFormatMessageFor(Level.ERROR, format, args), e); message = rawMessageFor(format, args); } logger.log(SEVERE, message, exception); } } }
Logger { public void error(Throwable exception, String format, Object... args) { if (logger.isLoggable(SEVERE)) { String message; try { message = format(format, args); } catch (IllegalFormatException e) { logger.log(SEVERE, illegalFormatMessageFor(Level.ERROR, format, args), e); message = rawMessageFor(format, args); } logger.log(SEVERE, message, exception); } } Logger(java.util.logging.Logger logger); }
Logger { public void error(Throwable exception, String format, Object... args) { if (logger.isLoggable(SEVERE)) { String message; try { message = format(format, args); } catch (IllegalFormatException e) { logger.log(SEVERE, illegalFormatMessageFor(Level.ERROR, format, args), e); message = rawMessageFor(format, args); } logger.log(SEVERE, 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 error(Throwable exception, String format, Object... args) { if (logger.isLoggable(SEVERE)) { String message; try { message = format(format, args); } catch (IllegalFormatException e) { logger.log(SEVERE, illegalFormatMessageFor(Level.ERROR, format, args), e); message = rawMessageFor(format, args); } logger.log(SEVERE, 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();  }