exConverter = new ThrowableProxyConverter(); tail.setNext(exConverter);
/** * This method computes whether a chain of converters handles exceptions or * not. * * @param head * The first element of the chain * @return true if can handle throwables contained in logging events */ public boolean chainHandlesThrowable(Converter<ILoggingEvent> head) { Converter<ILoggingEvent> c = head; while (c != null) { if (c instanceof ThrowableHandlingConverter) { return true; } c = c.getNext(); } return false; } }
public String convert(E event) { StringBuilder buf = new StringBuilder(); for (Converter<E> c = childConverter; c != null; c = c.next) { c.write(buf, event); } String intermediary = buf.toString(); return transform(event, intermediary); }
private void appendEventToBuffer(StringBuilder buf, Converter<ILoggingEvent> c, ILoggingEvent event) { buf.append("<td class=\""); buf.append(computeConverterName(c)); buf.append("\">"); buf.append(Transform.escapeTags(c.convert(event))); buf.append("</td>"); buf.append(LINE_SEPARATOR); }
public String doLayout(ILoggingEvent event) { StringBuilder buf = new StringBuilder(); startNewTableIfLimitReached(buf); boolean odd = true; if (((counter++) & 1) == 0) { odd = false; } String level = event.getLevel().toString().toLowerCase(); buf.append(LINE_SEPARATOR); buf.append("<tr class=\""); buf.append(level); if (odd) { buf.append(" odd\">"); } else { buf.append(" even\">"); } buf.append(LINE_SEPARATOR); Converter<ILoggingEvent> c = head; while (c != null) { appendEventToBuffer(buf, c, event); c = c.getNext(); } buf.append("</tr>"); buf.append(LINE_SEPARATOR); if (event.getThrowableProxy() != null) { throwableRenderer.render(buf, event); } return buf.toString(); }
private void appendEventToBuffer(StringBuilder buf, Converter<ILoggingEvent> c, ILoggingEvent event) { buf.append("<td class=\""); buf.append(computeConverterName(c)); buf.append("\">"); c.write(buf, event); buf.append("</td>"); buf.append(LINE_SEPARATOR); }
/** * In its simplest incarnation, a convert simply appends the data extracted from * the event to the buffer passed as parameter. * * @param buf The input buffer where data is appended * @param event The event from where data is extracted */ public void write(StringBuilder buf, E event) { buf.append(convert(event)); }
/** * Given date, convert this instance to a regular expression. * * Used to compute sub-regex when the pattern has both %d and %i, and the * date is known. */ public String toRegexForFixedDate(Date date) { StringBuilder buf = new StringBuilder(); Converter<Object> p = headTokenConverter; while (p != null) { if (p instanceof LiteralConverter) { buf.append(p.convert(null)); } else if (p instanceof IntegerTokenConverter) { buf.append("(\\d{1,3})"); } else if (p instanceof DateTokenConverter) { buf.append(p.convert(date)); } p = p.getNext(); } return buf.toString(); }
break; c = c.getNext();
private void addToList(Converter<E> c) { if (head == null) { head = tail = c; } else { tail.setNext(c); tail = c; } }
public String convert(E event) { StringBuilder buf = new StringBuilder(); for (Converter<E> c = childConverter; c != null; c = c.next) { c.write(buf, event); } String intermediary = buf.toString(); return transform(event, intermediary); }
/** * In its simplest incarnation, a convert simply appends the data extracted from * the event to the buffer passed as parameter. * * @param buf The input buffer where data is appended * @param event The event from where data is extracted */ public void write(StringBuilder buf, E event) { buf.append(convert(event)); }
public String convertMultipleArguments(Object... objectList) { StringBuilder buf = new StringBuilder(); Converter<Object> c = headTokenConverter; while (c != null) { if (c instanceof MonoTypedConverter) { MonoTypedConverter monoTyped = (MonoTypedConverter) c; for (Object o : objectList) { if (monoTyped.isApplicable(o)) { buf.append(c.convert(o)); } } } else { buf.append(c.convert(objectList)); } c = c.getNext(); } return buf.toString(); }
public IntegerTokenConverter getIntegerTokenConverter() { Converter p = headTokenConverter; while (p != null) { if (p instanceof IntegerTokenConverter) { return (IntegerTokenConverter) p; } p = p.getNext(); } return null; }
/** * This implementation checks if any of the converters in the chain handles * exceptions. If not, then this method adds a * {@link ExtendedThrowableProxyConverter} instance to the end of the chain. * <p> * This allows appenders using this layout to output exception information * event if the user forgets to add %ex to the pattern. Note that the * appenders defined in the Core package are not aware of exceptions nor * LoggingEvents. * <p> * If for some reason the user wishes to NOT print exceptions, then she can * add %nopex to the pattern. * * */ public void process(Converter<ILoggingEvent> head) { if(head == null) { // this should never happen throw new IllegalArgumentException("cannot process empty chain"); } if (!chainHandlesThrowable(head)) { Converter<ILoggingEvent> tail = ConverterUtil.findTail(head); Converter<ILoggingEvent> exConverter = new ExtendedThrowableProxyConverter(); tail.setNext(exConverter); } }
private void appendEventToBuffer(StringBuilder buf, Converter<IAccessEvent> c, IAccessEvent event) { buf.append("<td class=\""); buf.append(computeConverterName(c)); buf.append("\">"); c.write(buf, event); buf.append("</td>"); buf.append(LINE_SEPARATOR); } }