Class MemoryAppender

java.lang.Object
com.enterprisedt.util.debug.StreamAppender
com.enterprisedt.util.debug.MemoryAppender
All Implemented Interfaces:
Appender

public class MemoryAppender extends StreamAppender
Appends log statements to an in-memory buffer.
Version:
$Revision$
Author:
Hans Andersen
  • Field Details

    • DEFAULT_BUFFER_SIZE

      public static final int DEFAULT_BUFFER_SIZE
      Default size of memory-buffer (100k).
      See Also:
  • Constructor Details

    • MemoryAppender

      public MemoryAppender(int initSize)
      Create a MemoryAppender whose buffer has the given initial size.
      Parameters:
      size - Initial size of buffer.
    • MemoryAppender

      public MemoryAppender()
      Create a MemoryAppender whose buffer is initially set to 100k.
  • Method Details

    • getBuffer

      public byte[] getBuffer()
      Returns the current buffer.
      Returns:
      the current buffer.
    • getReader

      public Reader getReader()
      Returns a reader that may be used to access the current buffer. A snapshot of the buffer is taken at the time of invocation; any logging written to the appender after the invocation will not be accessible through the reader.
      Returns:
      A reader for the current buffer.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • print

      public void print(PrintStream stream)
      Writes the entire buffer to the given writer.
      Parameters:
      writer - Writer to write to.
    • print

      public void print()
      Writes the entire buffer to stdout.