Class LineTruncatingListener

  extended by logahawk.listeners.ProxyListener
      extended by logahawk.listeners.LineTruncatingListener
All Implemented Interfaces:

public class LineTruncatingListener
extends ProxyListener

Truncates long multi-line messages, replacing the truncated lines with an ellipsis (or other indicator). If the text has more lines than maxLineLength, the extra lines are removed such that the number of lines is one less than maxLineLength (leaving the last line for the suffix). Unlike LengthTruncatingListener this truncates based on line numbers, not based on overall length. This can be combined with LengthTruncatingListener to filter on both criteria, avoid long messages in both forms. This is intended for when logging objects that may produce many lines, such as the various CollectionArgFormatters. Displaying small collections is useful, and displaying the first few lines of a larger collection is useful, but displaying all lines may unnecessarily fill up the log. A good place to use this is with JLogViewer, where long log messages will force rapid scrolling.

Field Summary
protected  int maxLineLength
          Maximum number of lines passed to the proxied ProxyListener.listener after truncation.
protected  String suffix
          Suffix added to the text when truncation occurs.
Fields inherited from class logahawk.listeners.ProxyListener
Constructor Summary
LineTruncatingListener(Listener listener)
LineTruncatingListener(Listener listener, int maxLineLength)
LineTruncatingListener(Listener listener, int maxLineLength, String suffix)
Method Summary
 void log(LogMeta meta, String text)
          Logs the provided statement.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail


protected final int maxLineLength
Maximum number of lines passed to the proxied ProxyListener.listener after truncation. Default is 16 lines. All messages are assume to have a length of at least one.


protected final String suffix
Suffix added to the text when truncation occurs. Default value is "...". This value will have a Logger.LINE_SEPARATOR prepended to it in the constructor to avoid extra concatenation when logging.

Constructor Detail


public LineTruncatingListener(Listener listener)


public LineTruncatingListener(Listener listener,
                              int maxLineLength)


public LineTruncatingListener(Listener listener,
                              int maxLineLength,
                              String suffix)
Method Detail


public void log(LogMeta meta,
                String text)
Description copied from interface: Listener
Logs the provided statement. Normally this method should not throw any exceptions. If exceptions are expected it is recommend to wrap this Listener with a FailSafeListener.