com.hdcookbook.grinxlet
Class DebugLog

java.lang.Object
  extended by com.hdcookbook.grinxlet.DebugLog
All Implemented Interfaces:
java.lang.Runnable

public class DebugLog
extends java.lang.Object
implements java.lang.Runnable

A class to manage the debug log. The log is managed as static data; the constructor of this class is therefore private. When the debug log is active, a daemon thread runs that listens for telnet connections to view the log. The DebugLog class doesn't maintain any references outside of its own data in order to aid in xlet cleanup. When the surrounding xlet is destroyed, there might be a slight delay before the daemon thread terminates, but because the DebugLog class doesn't maintain any references to the xlet, there are no xlet references in the daemon thread's root set. This means that the rest of the xlet can be GC'd even if the daemon thread hasn't quite terminated yet.


Method Summary
static void print(java.lang.String s)
          Add s to the debug log, without a line break at the end.
static void println(java.lang.String s)
          Add s to the debug log, with a line break at the end.
 void run()
           
static void shutdownDebugListener()
           
static void startDebugListener()
          Start the DebugLog listening for incoming telnet connections.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

startDebugListener

public static void startDebugListener()
Start the DebugLog listening for incoming telnet connections. It's OK if this is called multiple times; in this case, only one thread will be created. Each call to startDebugListener() should eventually be balanced by a call to shutdownDebugListener(); after the last shutdown call, telnet connections are rendered inoperative, even if startDebugListener is subsequently called.

Throws:
java.lang.IllegalStateException - if the DebugLog has been shut down

run

public void run()
Specified by:
run in interface java.lang.Runnable

shutdownDebugListener

public static void shutdownDebugListener()
See Also:
startDebugListener()

print

public static void print(java.lang.String s)
Add s to the debug log, without a line break at the end.


println

public static void println(java.lang.String s)
Add s to the debug log, with a line break at the end.