@Test public void testFormatBackTrace() { Exception e = new IOException("Fake I/O"); e = new Exception(e.toString(), e); assertNotNull(e.getMessage(), e.getMessage()); CompactFormatter cf = new CompactFormatter(); LogRecord record = new LogRecord(Level.SEVERE, ""); record.setThrown(e); String result = cf.formatBackTrace(record); assertTrue(result, result.startsWith("CompactFormatterTest")); assertTrue(result, result.contains("testFormatBackTrace")); assertTrue(result, Character.isDigit(result.charAt(result.length() - 2))); }
public String formatBackTrace(LogRecord record) { String site = ""; final Throwable t = record.getThrown(); if (t != null) { final Throwable root = apply(t); if (root != null) { site = findAndFormat(root.getStackTrace()); if (isNullOrSpaces(site)) { int limit = 0; for (Throwable c = t; c != null; c = c.getCause()) { site = findAndFormat(c.getStackTrace()); if (!isNullOrSpaces(site)) { break; } if (++limit == (1 << 16)) { break; } } } } } return site; }
CompactFormatter extends java.util.logging.Formatter { public String formatBackTrace(LogRecord record) { String site = ""; final Throwable t = record.getThrown(); if (t != null) { final Throwable root = apply(t); if (root != null) { site = findAndFormat(root.getStackTrace()); if (isNullOrSpaces(site)) { int limit = 0; for (Throwable c = t; c != null; c = c.getCause()) { site = findAndFormat(c.getStackTrace()); if (!isNullOrSpaces(site)) { break; } if (++limit == (1 << 16)) { break; } } } } } return site; } }
CompactFormatter extends java.util.logging.Formatter { public String formatBackTrace(LogRecord record) { String site = ""; final Throwable t = record.getThrown(); if (t != null) { final Throwable root = apply(t); if (root != null) { site = findAndFormat(root.getStackTrace()); if (isNullOrSpaces(site)) { int limit = 0; for (Throwable c = t; c != null; c = c.getCause()) { site = findAndFormat(c.getStackTrace()); if (!isNullOrSpaces(site)) { break; } if (++limit == (1 << 16)) { break; } } } } } return site; } CompactFormatter();  CompactFormatter(final String format); }
CompactFormatter extends java.util.logging.Formatter { public String formatBackTrace(LogRecord record) { String site = ""; final Throwable t = record.getThrown(); if (t != null) { final Throwable root = apply(t); if (root != null) { site = findAndFormat(root.getStackTrace()); if (isNullOrSpaces(site)) { int limit = 0; for (Throwable c = t; c != null; c = c.getCause()) { site = findAndFormat(c.getStackTrace()); if (!isNullOrSpaces(site)) { break; } if (++limit == (1 << 16)) { break; } } } } } return site; } 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); }
CompactFormatter extends java.util.logging.Formatter { public String formatBackTrace(LogRecord record) { String site = ""; final Throwable t = record.getThrown(); if (t != null) { final Throwable root = apply(t); if (root != null) { site = findAndFormat(root.getStackTrace()); if (isNullOrSpaces(site)) { int limit = 0; for (Throwable c = t; c != null; c = c.getCause()) { site = findAndFormat(c.getStackTrace()); if (!isNullOrSpaces(site)) { break; } if (++limit == (1 << 16)) { break; } } } } } return site; } 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);  }