edu.rice.cs.plt.debug
Class TextLogSink

java.lang.Object
  extended by edu.rice.cs.plt.debug.TextLogSink
All Implemented Interfaces:
LogSink, Closeable
Direct Known Subclasses:
AssertEmptyLogSink, IndentedTextLogSink, PopupLogSink, TreeLogSink

public abstract class TextLogSink
extends Object
implements LogSink

A LogSink that formats its messages as lines of text. Subclasses are responsible for writing that text to an appropriate location.


Nested Class Summary
 
Nested classes/interfaces inherited from interface edu.rice.cs.plt.debug.LogSink
LogSink.EndMessage, LogSink.ErrorMessage, LogSink.Message, LogSink.MessageVisitor<T>, LogSink.StackMessage, LogSink.StandardMessage, LogSink.StartMessage, LogSink.ValueMessage
 
Constructor Summary
protected TextLogSink()
           
protected TextLogSink(int idealLineWidth)
           
 
Method Summary
protected static String formatLocation(Option<StackTraceElement> location)
          Convert a location to a string of the form "edu.rice.cs.plt.debug.TextLogSink.formatLocation(24)"
protected static String formatLocation(StackTraceElement location)
          Convert a location to a string of the form "edu.rice.cs.plt.debug.TextLogSink.formatLocation(24)"
protected static String formatThread(ThreadSnapshot thread)
          Convert a thread to a string of the form "Custom Thread 22", consisting of the thread's name and id.
protected static String formatTime(Date time)
          Convert a time to a string of the form "12:23:03.013"
 void log(LogSink.StandardMessage m)
           
 void logEnd(LogSink.EndMessage m)
           
 void logError(LogSink.ErrorMessage m)
           
 void logStack(LogSink.StackMessage m)
           
 void logStart(LogSink.StartMessage m)
           
protected abstract  void write(LogSink.Message m, SizedIterable<String> text)
          Record the given message, the body of which is described by the given lines of text.
protected abstract  void writeEnd(LogSink.EndMessage m, SizedIterable<String> text)
          Record the given end message, the body of which is described by the given lines of text.
protected abstract  void writeStart(LogSink.StartMessage m, SizedIterable<String> text)
          Record the given start message, the body of which is described by the given lines of text.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.io.Closeable
close
 

Constructor Detail

TextLogSink

protected TextLogSink()

TextLogSink

protected TextLogSink(int idealLineWidth)
Method Detail

write

protected abstract void write(LogSink.Message m,
                              SizedIterable<String> text)
Record the given message, the body of which is described by the given lines of text. Subclasses should ensure that the effects of this method appear to be atomic (at least within the context of concurrent invocations of this method). This can be trivially achieved by declaring the method synchronized.


writeStart

protected abstract void writeStart(LogSink.StartMessage m,
                                   SizedIterable<String> text)
Record the given start message, the body of which is described by the given lines of text. Subclasses should ensure that the effects of this method appear to be atomic (at least within the context of concurrent invocations of this method). This can be trivially achieved by declaring the method synchronized.


writeEnd

protected abstract void writeEnd(LogSink.EndMessage m,
                                 SizedIterable<String> text)
Record the given end message, the body of which is described by the given lines of text. Subclasses should ensure that the effects of this method appear to be atomic (at least within the context of concurrent invocations of this method). This can be trivially achieved by declaring the method synchronized.


formatTime

protected static String formatTime(Date time)
Convert a time to a string of the form "12:23:03.013"


formatThread

protected static String formatThread(ThreadSnapshot thread)
Convert a thread to a string of the form "Custom Thread 22", consisting of the thread's name and id.


formatLocation

protected static String formatLocation(Option<StackTraceElement> location)
Convert a location to a string of the form "edu.rice.cs.plt.debug.TextLogSink.formatLocation(24)"


formatLocation

protected static String formatLocation(StackTraceElement location)
Convert a location to a string of the form "edu.rice.cs.plt.debug.TextLogSink.formatLocation(24)"


log

public void log(LogSink.StandardMessage m)
Specified by:
log in interface LogSink

logStart

public void logStart(LogSink.StartMessage m)
Specified by:
logStart in interface LogSink

logEnd

public void logEnd(LogSink.EndMessage m)
Specified by:
logEnd in interface LogSink

logError

public void logError(LogSink.ErrorMessage m)
Specified by:
logError in interface LogSink

logStack

public void logStack(LogSink.StackMessage m)
Specified by:
logStack in interface LogSink