logahawk.listeners
Class LineTruncatingListener

java.lang.Object
  extended by logahawk.listeners.ProxyListener
      extended by logahawk.listeners.LineTruncatingListener
All Implemented Interfaces:
Listener

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
listener
 
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

maxLineLength

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.


suffix

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

LineTruncatingListener

public LineTruncatingListener(Listener listener)

LineTruncatingListener

public LineTruncatingListener(Listener listener,
                              int maxLineLength)

LineTruncatingListener

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

log

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.