org.erights.e.develop.trace
Class TraceBuffer

java.lang.Object
  |
  +--org.erights.e.develop.trace.TraceBuffer
All Implemented Interfaces:
TraceConstants, TraceMessageAcceptor

class TraceBuffer
extends Object
implements TraceMessageAcceptor, TraceConstants


Field Summary
static String[] acceptorNames
           
static int ADD
           
private  int currentSize
          The current number.
static int DEBUG
           
static String DEFAULT_NAME
           
private  TraceMessage end
          The last message in the buffer.
static int ERROR
          The different trace thresholds.
static int EVENT
           
static int FOR_SUBSYSTEM
           
static int FROM_DEFAULT
          When referring to thresholds, are we talking about those from the default thresholds, or ones specific to a subsystem? XXX These could be interned strings, but interning didn't work right in 1.0.4.
static int IRRELEVANT
           
static int LOG
          This identifies the TraceMessageAcceptor used for the on-disk log.
static String LOG_EXTENSION
           
static int MAX_THRESHOLD
           
private  int maxSize
          The max number of messages between start and end (inclusive).
private  Object myLock
           
static int NUM_ACCEPTORS
          The number of different types of TraceMessageAcceptors.
static int OVERWRITE
           
static String[] reasonNames
           
static long SMALLEST_LOG_SIZE_THRESHOLD
           
private  TraceMessage start
          The first message in the buffer.
static int STARTING_LOG_BACKUP_ACTION
           
static File STARTING_LOG_DIR
           
static long STARTING_LOG_SIZE_THRESHOLD
           
static String STARTING_LOG_TAG
           
static int STARTING_LOG_THRESHOLD
           
static boolean STARTING_LOG_WRITE
           
static int STARTING_TRACE_BUFFER_SIZE
           
static int STARTING_TRACE_THRESHOLD
           
static int TIMING
          As a late addition, there's a "timing" boolean that can be set orthogonally from the thresholds.
static int TRACE
          This identifies the TraceMessageAcceptor used for the in-core trace and its associated window.
static String UNLIMITED_NAME
           
static int USAGE
           
static int VERBOSE
           
static String version
           
static int WARNING
           
static int WORLD
           
 
Constructor Summary
(package private) TraceBuffer()
           
 
Method Summary
 void accept(TraceMessage message)
          Accept a message and do whatever is appropriate to make it visible to a user, either now or later.
(package private)  void changeSize(String value)
           
(package private)  void dump(String destination)
          Dump the buffer to a file.
(package private)  void dump(TraceMessageAcceptor acceptor)
          Dump the buffer to a TraceMessageAcceptor.
(package private)  TraceMessage getFirstMessage()
           
private  TraceMessage recordTraceMessageXyzzY(String message, int level)
           
 void setupIsComplete()
          After this call, the TraceMessageAcceptor must obey settings from the environment.
private  TraceMessage unpostedTraceMessage(String message, int level)
          Create a trace message that isn't posted to all the message acceptors.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myLock

private final Object myLock

start

private TraceMessage start
The first message in the buffer.


end

private TraceMessage end
The last message in the buffer.


maxSize

private int maxSize
The max number of messages between start and end (inclusive).


currentSize

private int currentSize
The current number.


version

public static final String version

LOG

public static final int LOG
This identifies the TraceMessageAcceptor used for the on-disk log.


TRACE

public static final int TRACE
This identifies the TraceMessageAcceptor used for the in-core trace and its associated window.


NUM_ACCEPTORS

public static final int NUM_ACCEPTORS
The number of different types of TraceMessageAcceptors.


acceptorNames

public static final String[] acceptorNames

ERROR

public static final int ERROR
The different trace thresholds. See the Trace class for documentation. There is space between the levels for expansion. If you add or delete a level, you must change Trace.java to add new methods and variables.


WARNING

public static final int WARNING

WORLD

public static final int WORLD

USAGE

public static final int USAGE

EVENT

public static final int EVENT

DEBUG

public static final int DEBUG

VERBOSE

public static final int VERBOSE

MAX_THRESHOLD

public static final int MAX_THRESHOLD

TIMING

public static final int TIMING
As a late addition, there's a "timing" boolean that can be set orthogonally from the thresholds. The above values are overloaded: thresholds, but also identifiers for the original message (was it sent with errorm(), etc.). The TIMING "level" is added for the latter purpose, but it has nothing to do with thresholds. To avoid confusion, it's set negative, thus below the minimum threshold.


FROM_DEFAULT

public static final int FROM_DEFAULT
When referring to thresholds, are we talking about those from the default thresholds, or ones specific to a subsystem? XXX These could be interned strings, but interning didn't work right in 1.0.4. That is, two "default" strings weren't eq.


FOR_SUBSYSTEM

public static final int FOR_SUBSYSTEM

reasonNames

public static final String[] reasonNames

STARTING_TRACE_BUFFER_SIZE

public static final int STARTING_TRACE_BUFFER_SIZE

STARTING_TRACE_THRESHOLD

public static final int STARTING_TRACE_THRESHOLD

STARTING_LOG_SIZE_THRESHOLD

public static final long STARTING_LOG_SIZE_THRESHOLD

SMALLEST_LOG_SIZE_THRESHOLD

public static final long SMALLEST_LOG_SIZE_THRESHOLD

STARTING_LOG_THRESHOLD

public static final int STARTING_LOG_THRESHOLD

STARTING_LOG_WRITE

public static final boolean STARTING_LOG_WRITE

IRRELEVANT

public static final int IRRELEVANT

ADD

public static final int ADD

OVERWRITE

public static final int OVERWRITE

STARTING_LOG_BACKUP_ACTION

public static final int STARTING_LOG_BACKUP_ACTION

STARTING_LOG_DIR

public static final File STARTING_LOG_DIR

STARTING_LOG_TAG

public static final String STARTING_LOG_TAG

LOG_EXTENSION

public static final String LOG_EXTENSION

DEFAULT_NAME

public static final String DEFAULT_NAME

UNLIMITED_NAME

public static final String UNLIMITED_NAME
Constructor Detail

TraceBuffer

TraceBuffer()
Method Detail

accept

public void accept(TraceMessage message)
Description copied from interface: TraceMessageAcceptor
Accept a message and do whatever is appropriate to make it visible to a user, either now or later.

Note that this method should be called AFTER the message passes a priority threshold check. MessageAcceptors don't know about priorities.

The TraceMessageAcceptor is allowed to unilaterally discard the message. Generally, this is done only if it was turned off by another thread.

Specified by:
accept in interface TraceMessageAcceptor

changeSize

void changeSize(String value)

dump

void dump(String destination)
Dump the buffer to a file. This is a quasi-temporary function. It would be better (probably) if the buffer were dumped to a window, which could then be dumped to a file. TraceDisplay.java is an early attempt at that, but foundered on lack of time and dependencies on classes that aren't built until long after trace.


dump

void dump(TraceMessageAcceptor acceptor)
Dump the buffer to a TraceMessageAcceptor.


getFirstMessage

TraceMessage getFirstMessage()

setupIsComplete

public void setupIsComplete()
Description copied from interface: TraceMessageAcceptor
After this call, the TraceMessageAcceptor must obey settings from the environment. Before this call, it must defer taking any visible action, because it can't yet know what action is appropriate. Note that the message acceptor may (is encouraged to) accept messages before setup is complete, because some of those trace messages might be useful.

It is an error to call this method more than once.

Specified by:
setupIsComplete in interface TraceMessageAcceptor

unpostedTraceMessage

private TraceMessage unpostedTraceMessage(String message,
                                          int level)
Create a trace message that isn't posted to all the message acceptors. Used for messages that have one specific destination.


recordTraceMessageXyzzY

private TraceMessage recordTraceMessageXyzzY(String message,
                                             int level)


comments?