@Test public void testDump3() throws Throwable { new LogEvent(new ThreadPool(0, 0), "testString", null).dump(new PrintStream(new ByteArrayOutputStream(), true), "a42"); assertEquals("a42", "a42", "\"a42\""); }
public void dump (PrintStream p, String outer) { try { String indent = dumpHeader (p, outer); if (payLoad.isEmpty()) { if (tag != null) p.println (indent + "<" + tag + "/>"); } else { String newIndent; if (tag != null) { if (!tag.isEmpty()) p.println (indent + "<" + tag + ">"); newIndent = indent + " "; } else newIndent = ""; synchronized (payLoad) { for (Object o : payLoad) { if (o instanceof Loggeable) ((Loggeable) o).dump(p, newIndent); else if (o instanceof SQLException) { SQLException e = (SQLException) o; p.println(newIndent + "<SQLException>" + e.getMessage() + "</SQLException>"); p.println(newIndent + "<SQLState>" + e.getSQLState() + "</SQLState>"); p.println(newIndent + "<VendorError>" + e.getErrorCode() + "</VendorError>"); ((Throwable) o).printStackTrace(p); } else if (o instanceof Throwable) { p.println(newIndent + "<exception name=\"" + ((Throwable) o).getMessage() + "\">"); p.print(newIndent); ((Throwable) o).printStackTrace(p); p.println(newIndent + "</exception>"); } else if (o instanceof Object[]) { Object[] oa = (Object[]) o; p.print(newIndent + "["); for (int j = 0; j < oa.length; j++) { if (j > 0) p.print(","); p.print(oa[j].toString()); } p.println("]"); } else if (o instanceof Element) { p.println(""); XMLOutputter out = new XMLOutputter(Format.getPrettyFormat()); out.getFormat().setLineSeparator("\n"); try { out.output((Element) o, p); } catch (IOException ex) { ex.printStackTrace(p); } p.println(""); } else if (o != null) { p.println(newIndent + o.toString()); } else { p.println(newIndent + "null"); } } } if (tag != null && !tag.isEmpty()) p.println (indent + "</" + tag + ">"); } } catch (Throwable t) { t.printStackTrace(p); } finally { dumpTrailer (p, outer); } }
LogEvent { public void dump (PrintStream p, String outer) { try { String indent = dumpHeader (p, outer); if (payLoad.isEmpty()) { if (tag != null) p.println (indent + "<" + tag + "/>"); } else { String newIndent; if (tag != null) { if (!tag.isEmpty()) p.println (indent + "<" + tag + ">"); newIndent = indent + " "; } else newIndent = ""; synchronized (payLoad) { for (Object o : payLoad) { if (o instanceof Loggeable) ((Loggeable) o).dump(p, newIndent); else if (o instanceof SQLException) { SQLException e = (SQLException) o; p.println(newIndent + "<SQLException>" + e.getMessage() + "</SQLException>"); p.println(newIndent + "<SQLState>" + e.getSQLState() + "</SQLState>"); p.println(newIndent + "<VendorError>" + e.getErrorCode() + "</VendorError>"); ((Throwable) o).printStackTrace(p); } else if (o instanceof Throwable) { p.println(newIndent + "<exception name=\"" + ((Throwable) o).getMessage() + "\">"); p.print(newIndent); ((Throwable) o).printStackTrace(p); p.println(newIndent + "</exception>"); } else if (o instanceof Object[]) { Object[] oa = (Object[]) o; p.print(newIndent + "["); for (int j = 0; j < oa.length; j++) { if (j > 0) p.print(","); p.print(oa[j].toString()); } p.println("]"); } else if (o instanceof Element) { p.println(""); XMLOutputter out = new XMLOutputter(Format.getPrettyFormat()); out.getFormat().setLineSeparator("\n"); try { out.output((Element) o, p); } catch (IOException ex) { ex.printStackTrace(p); } p.println(""); } else if (o != null) { p.println(newIndent + o.toString()); } else { p.println(newIndent + "null"); } } } if (tag != null && !tag.isEmpty()) p.println (indent + "</" + tag + ">"); } } catch (Throwable t) { t.printStackTrace(p); } finally { dumpTrailer (p, outer); } } }
LogEvent { public void dump (PrintStream p, String outer) { try { String indent = dumpHeader (p, outer); if (payLoad.isEmpty()) { if (tag != null) p.println (indent + "<" + tag + "/>"); } else { String newIndent; if (tag != null) { if (!tag.isEmpty()) p.println (indent + "<" + tag + ">"); newIndent = indent + " "; } else newIndent = ""; synchronized (payLoad) { for (Object o : payLoad) { if (o instanceof Loggeable) ((Loggeable) o).dump(p, newIndent); else if (o instanceof SQLException) { SQLException e = (SQLException) o; p.println(newIndent + "<SQLException>" + e.getMessage() + "</SQLException>"); p.println(newIndent + "<SQLState>" + e.getSQLState() + "</SQLState>"); p.println(newIndent + "<VendorError>" + e.getErrorCode() + "</VendorError>"); ((Throwable) o).printStackTrace(p); } else if (o instanceof Throwable) { p.println(newIndent + "<exception name=\"" + ((Throwable) o).getMessage() + "\">"); p.print(newIndent); ((Throwable) o).printStackTrace(p); p.println(newIndent + "</exception>"); } else if (o instanceof Object[]) { Object[] oa = (Object[]) o; p.print(newIndent + "["); for (int j = 0; j < oa.length; j++) { if (j > 0) p.print(","); p.print(oa[j].toString()); } p.println("]"); } else if (o instanceof Element) { p.println(""); XMLOutputter out = new XMLOutputter(Format.getPrettyFormat()); out.getFormat().setLineSeparator("\n"); try { out.output((Element) o, p); } catch (IOException ex) { ex.printStackTrace(p); } p.println(""); } else if (o != null) { p.println(newIndent + o.toString()); } else { p.println(newIndent + "null"); } } } if (tag != null && !tag.isEmpty()) p.println (indent + "</" + tag + ">"); } } catch (Throwable t) { t.printStackTrace(p); } finally { dumpTrailer (p, outer); } } LogEvent(String tag);  LogEvent();  LogEvent(String tag, Object msg);  LogEvent(LogSource source, String tag);  LogEvent(LogSource source, String tag, Object msg); }
LogEvent { public void dump (PrintStream p, String outer) { try { String indent = dumpHeader (p, outer); if (payLoad.isEmpty()) { if (tag != null) p.println (indent + "<" + tag + "/>"); } else { String newIndent; if (tag != null) { if (!tag.isEmpty()) p.println (indent + "<" + tag + ">"); newIndent = indent + " "; } else newIndent = ""; synchronized (payLoad) { for (Object o : payLoad) { if (o instanceof Loggeable) ((Loggeable) o).dump(p, newIndent); else if (o instanceof SQLException) { SQLException e = (SQLException) o; p.println(newIndent + "<SQLException>" + e.getMessage() + "</SQLException>"); p.println(newIndent + "<SQLState>" + e.getSQLState() + "</SQLState>"); p.println(newIndent + "<VendorError>" + e.getErrorCode() + "</VendorError>"); ((Throwable) o).printStackTrace(p); } else if (o instanceof Throwable) { p.println(newIndent + "<exception name=\"" + ((Throwable) o).getMessage() + "\">"); p.print(newIndent); ((Throwable) o).printStackTrace(p); p.println(newIndent + "</exception>"); } else if (o instanceof Object[]) { Object[] oa = (Object[]) o; p.print(newIndent + "["); for (int j = 0; j < oa.length; j++) { if (j > 0) p.print(","); p.print(oa[j].toString()); } p.println("]"); } else if (o instanceof Element) { p.println(""); XMLOutputter out = new XMLOutputter(Format.getPrettyFormat()); out.getFormat().setLineSeparator("\n"); try { out.output((Element) o, p); } catch (IOException ex) { ex.printStackTrace(p); } p.println(""); } else if (o != null) { p.println(newIndent + o.toString()); } else { p.println(newIndent + "null"); } } } if (tag != null && !tag.isEmpty()) p.println (indent + "</" + tag + ">"); } } catch (Throwable t) { t.printStackTrace(p); } finally { dumpTrailer (p, outer); } } LogEvent(String tag);  LogEvent();  LogEvent(String tag, Object msg);  LogEvent(LogSource source, String tag);  LogEvent(LogSource source, String tag, Object msg); String getTag(); void setTag(String tag); void addMessage(Object msg); void addMessage(String tagname, String message); LogSource getSource(); void setSource(LogSource source); void setNoArmor(boolean noArmor); void dump(PrintStream p, String outer); String getRealm(); List<Object> getPayLoad(); String toString(String indent); String toString(); boolean isHonorSourceLogger(); }
LogEvent { public void dump (PrintStream p, String outer) { try { String indent = dumpHeader (p, outer); if (payLoad.isEmpty()) { if (tag != null) p.println (indent + "<" + tag + "/>"); } else { String newIndent; if (tag != null) { if (!tag.isEmpty()) p.println (indent + "<" + tag + ">"); newIndent = indent + " "; } else newIndent = ""; synchronized (payLoad) { for (Object o : payLoad) { if (o instanceof Loggeable) ((Loggeable) o).dump(p, newIndent); else if (o instanceof SQLException) { SQLException e = (SQLException) o; p.println(newIndent + "<SQLException>" + e.getMessage() + "</SQLException>"); p.println(newIndent + "<SQLState>" + e.getSQLState() + "</SQLState>"); p.println(newIndent + "<VendorError>" + e.getErrorCode() + "</VendorError>"); ((Throwable) o).printStackTrace(p); } else if (o instanceof Throwable) { p.println(newIndent + "<exception name=\"" + ((Throwable) o).getMessage() + "\">"); p.print(newIndent); ((Throwable) o).printStackTrace(p); p.println(newIndent + "</exception>"); } else if (o instanceof Object[]) { Object[] oa = (Object[]) o; p.print(newIndent + "["); for (int j = 0; j < oa.length; j++) { if (j > 0) p.print(","); p.print(oa[j].toString()); } p.println("]"); } else if (o instanceof Element) { p.println(""); XMLOutputter out = new XMLOutputter(Format.getPrettyFormat()); out.getFormat().setLineSeparator("\n"); try { out.output((Element) o, p); } catch (IOException ex) { ex.printStackTrace(p); } p.println(""); } else if (o != null) { p.println(newIndent + o.toString()); } else { p.println(newIndent + "null"); } } } if (tag != null && !tag.isEmpty()) p.println (indent + "</" + tag + ">"); } } catch (Throwable t) { t.printStackTrace(p); } finally { dumpTrailer (p, outer); } } LogEvent(String tag);  LogEvent();  LogEvent(String tag, Object msg);  LogEvent(LogSource source, String tag);  LogEvent(LogSource source, String tag, Object msg); String getTag(); void setTag(String tag); void addMessage(Object msg); void addMessage(String tagname, String message); LogSource getSource(); void setSource(LogSource source); void setNoArmor(boolean noArmor); void dump(PrintStream p, String outer); String getRealm(); List<Object> getPayLoad(); String toString(String indent); String toString(); boolean isHonorSourceLogger();  }