Package com.enterprisedt.util.debug
Class MemoryAppender
java.lang.Object
com.enterprisedt.util.debug.StreamAppender
com.enterprisedt.util.debug.MemoryAppender
- All Implemented Interfaces:
Appender
Appends log statements to an in-memory buffer.
- Version:
- $Revision$
- Author:
- Hans Andersen
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault size of memory-buffer (100k).Fields inherited from class com.enterprisedt.util.debug.StreamAppender
log, outStr -
Constructor Summary
ConstructorsConstructorDescriptionCreate a MemoryAppender whose buffer is initially set to 100k.MemoryAppender(int initSize) Create a MemoryAppender whose buffer has the given initial size. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]Returns the current buffer.Returns a reader that may be used to access the current buffer.voidprint()Writes the entire buffer to stdout.voidprint(PrintStream stream) Writes the entire buffer to the given writer.toString()Methods inherited from class com.enterprisedt.util.debug.StreamAppender
close, log, log
-
Field Details
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZEDefault 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
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
-
print
Writes the entire buffer to the given writer.- Parameters:
writer- Writer to write to.
-
print
public void print()Writes the entire buffer to stdout.
-