com.threerings.bureau.util
Class BureauLogRedirector

java.lang.Object
  extended by com.threerings.bureau.util.BureauLogRedirector

public class BureauLogRedirector
extends Object

Captures the output of a bureau and redirects it into a single logger instance using a thread name equal to the bureau id. The Logger instance is the one for this class. The intent is that log4j will be configured to use %t (thread name) to embed the bureau id.


Field Summary
protected  String _bureauId
           
protected  int _limit
           
protected  BufferedReader _reader
           
protected static Logger _target
           
protected  boolean _truncated
           
protected  int _written
           
 
Constructor Summary
BureauLogRedirector(String bureauId, InputStream input)
          Creates a new redirector with no size limit.
BureauLogRedirector(String bureauId, InputStream input, int limit)
          Creates a new redirector.
 
Method Summary
protected  void copyLoop()
           
 String getBureauId()
          Gets the bureau id this was created with.
 int getLimit()
          Gets the character limit associated with the log.
 int getWritten()
          Gets the total number of characters written to the log.
 boolean isRunning()
          Returns true if the redirector is still active.
 boolean isTruncated()
          Tests if this redirector has stopped copying lines due to the size limit being exceeded.
 void reset(int limit)
          Resets the redirector's truncation status and allows additional output up to the given character limit.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_bureauId

protected String _bureauId

_reader

protected BufferedReader _reader

_limit

protected int _limit

_written

protected int _written

_truncated

protected boolean _truncated

_target

protected static Logger _target
Constructor Detail

BureauLogRedirector

public BureauLogRedirector(String bureauId,
                           InputStream input)
Creates a new redirector with no size limit.

Parameters:
bureauId - the id of the bureau being redirected - this will become the thread name
input - the stream that is the output of the bureau process

BureauLogRedirector

public BureauLogRedirector(String bureauId,
                           InputStream input,
                           int limit)
Creates a new redirector.

Parameters:
bureauId - the id of the bureau being redirected - this will become the thread name
input - the stream that is the output of the bureau process
limit - approximate limit for the total characters written to the logger
Method Detail

getBureauId

public String getBureauId()
Gets the bureau id this was created with.


getWritten

public int getWritten()
Gets the total number of characters written to the log.


getLimit

public int getLimit()
Gets the character limit associated with the log.


reset

public void reset(int limit)
Resets the redirector's truncation status and allows additional output up to the given character limit.


isTruncated

public boolean isTruncated()
Tests if this redirector has stopped copying lines due to the size limit being exceeded.


isRunning

public boolean isRunning()
Returns true if the redirector is still active. Normally this indicates that the launched process is still running.


copyLoop

protected void copyLoop()