CompactFormatter extends java.util.logging.Formatter { public String formatLoggerName(final LogRecord record) { return simpleClassName(record.getLoggerName()); } CompactFormatter();  CompactFormatter(final String format); @Override String format(final LogRecord record); @Override String formatMessage(final LogRecord record); String formatMessage(final Throwable t); String formatLevel(final LogRecord record); String formatSource(final LogRecord record); String formatLoggerName(final LogRecord record); String formatThrown(final LogRecord record); String formatBackTrace(LogRecord record);  }
@Test public void testFormatLogger() { CompactFormatter cf = new CompactFormatter(); LogRecord record = new LogRecord(Level.SEVERE, ""); record.setSourceMethodName(null); record.setSourceClassName(null); record.setLoggerName(Object.class.getName()); String result = cf.formatLoggerName(record); assertEquals(Object.class.getSimpleName(), result); }
@Test(expected = NullPointerException.class) public void testFormatLoggerNull() { CompactFormatter cf = new CompactFormatter(); cf.formatLoggerName((LogRecord) null); fail(cf.toString()); }