|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.erights.e.develop.trace.TraceLog
This class manages dumping of messages to the semi-permanent on-disk log.
Field Summary | |
static String[] |
acceptorNames
|
static int |
ADD
|
static int |
DEBUG
|
static String |
DEFAULT_NAME
|
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
|
private static int |
lineSeparatorLength
This variable is used to count accurately the size of the log. |
static int |
LOG
This identifies the TraceMessageAcceptor used for the on-disk log. |
static String |
LOG_EXTENSION
|
static int |
MAX_THRESHOLD
|
private int |
myBackupAction
Determine whether to rename full log files and open new ones, or to empty a full log file. |
private TraceLogDescriptor |
myCurrent
The log to which messages are currently flowing. |
private long |
myCurrentSize
Number of characters in the current log file. |
private Object |
myLock
|
private long |
myMaxSize
The definition, in number of characters, of what a full log file is. |
private TraceLogDescriptor |
myPending
The user can change the characteristics of this log descriptor, then redirect the log to it. |
private boolean |
mySetupComplete
True if all the initial properties have been processed. |
private TraceMessageStringifier |
myStringifier
This converts a TraceMessage into the kind of string we like. |
private boolean |
myWrite
Determine whether a log file should be written at all. |
static int |
NUM_ACCEPTORS
The number of different types of TraceMessageAcceptors. |
static int |
OVERWRITE
|
private Vector |
queuedMessages
Messages are queued here before the Log is initialized and while switching to a new logfile. |
static String[] |
reasonNames
|
static long |
SMALLEST_LOG_SIZE_THRESHOLD
|
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) |
TraceLog()
Construct the trace log. |
Method Summary | |
void |
accept(TraceMessage message)
Accept a message for the log. |
private void |
acceptBypassingQueue(TraceMessage message)
that we will Take a message and log it. |
private void |
beginLogging()
Call to initialize a log when logging is just beginning (or resuming after having been turned off). |
(package private) void |
changeBackupFileHandling(String newBehavior)
Change how a full logfile handles its backup files. |
(package private) void |
changeDir(String value)
Change the default directory in which logfiles live. |
(package private) void |
changeName(String value)
Explicitly set the name of the next logfile to open. |
(package private) void |
changeSize(String value)
Change the new maximum allowable size for a logfile. |
(package private) void |
changeTag(String value)
Change the 'tag' (base of filename) that logfiles have. |
(package private) void |
changeWrite(String value)
The meaning of changeWrite is complicated. |
private void |
drainQueue()
Deal with messages on the queue. |
private void |
handleFullLog()
Call when the logfile fills up. |
private void |
hotSwap()
Call to switch to a log when another - with a different name - is currently being used. |
private boolean |
isAcceptingMessages()
The log accepts messages if the "TraceLog_write" property was set. |
private boolean |
isQueuing()
|
(package private) void |
reopen(String ignored)
The gist of this routine is that it shuts down the current log and reopens a new one (possibly with the same name, possibly with a different name). |
void |
setupIsComplete()
Call this only after all properties have been processed. |
private void |
shutdownAndSwap()
Call to initialize a log when the same file is already open. |
private void |
startQueuing()
Redirect trace messages to a queue. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private final Object myLock
private int myBackupAction
private boolean myWrite
private long myMaxSize
private long myCurrentSize
private TraceLogDescriptor myCurrent
private TraceLogDescriptor myPending
Characteristics are changed via properties like "TraceLog_tag". Redirection is done via "TraceLog_reopen".
private boolean mySetupComplete
private final TraceMessageStringifier myStringifier
private static final int lineSeparatorLength
private Vector queuedMessages
public static final String version
public static final int LOG
public static final int TRACE
public static final int NUM_ACCEPTORS
public static final String[] acceptorNames
public static final int ERROR
public static final int WARNING
public static final int WORLD
public static final int USAGE
public static final int EVENT
public static final int DEBUG
public static final int VERBOSE
public static final int MAX_THRESHOLD
public static final int TIMING
public static final int FROM_DEFAULT
public static final int FOR_SUBSYSTEM
public static final String[] reasonNames
public static final int STARTING_TRACE_BUFFER_SIZE
public static final int STARTING_TRACE_THRESHOLD
public static final long STARTING_LOG_SIZE_THRESHOLD
public static final long SMALLEST_LOG_SIZE_THRESHOLD
public static final int STARTING_LOG_THRESHOLD
public static final boolean STARTING_LOG_WRITE
public static final int IRRELEVANT
public static final int ADD
public static final int OVERWRITE
public static final int STARTING_LOG_BACKUP_ACTION
public static final File STARTING_LOG_DIR
public static final String STARTING_LOG_TAG
public static final String LOG_EXTENSION
public static final String DEFAULT_NAME
public static final String UNLIMITED_NAME
Constructor Detail |
TraceLog()
Method Detail |
public void accept(TraceMessage message)
accept
in interface TraceMessageAcceptor
private void acceptBypassingQueue(TraceMessage message)
private void beginLogging()
void changeBackupFileHandling(String newBehavior)
void changeDir(String value)
void changeName(String value)
void changeSize(String value)
void changeTag(String value)
void changeWrite(String value)
If setup is still in progress, the state variable 'myWrite' is used to note that logging should begin when setupIsComplete() is called.
If setup is complete, logging should begin immediately. If logging has already begun, this is a no-op.
Here are the cases for turning writing OFF.
If setup is not complete, the state variable 'myWrite' informs setupIsComplete() that logging should not begin.
If setup is complete, logging is stopped. However, if it was already stopped, the call is a no-op.
There would be some merit in having a state machine implement all this.
private final void drainQueue()
private void handleFullLog()
Standard output can never fill up, so this routine is a no-op when the current size of text sent to standard out exceeds the maximum, except that the current size is reset to zero.
private void hotSwap()
Before the old log is closed, a USAGE message is logged, directing the reader to the new log. Trace messages may be queued while the swap is happening, but the queue is drained before the method returns.
This routine is never called when the logfile fills - it's only used when explicitly reopening a log file. (TraceLog_reopen=true).
private final boolean isAcceptingMessages()
Queuing also happens transitorily while logs are being switched.
private final boolean isQueuing()
void reopen(String ignored)
When it's called before setup is complete and writing is not enabled, the behavior is the same as TraceLog_write [the preferred interface].
When it's called before setup is complete and writing is enabled, the effect is that of calling TraceLog_write twice (a warning).
When it's called after setup is complete and writing is not enabled, the behavior is the same as calling TraceLog_write [again, the preferred interface, because you're not "reopening" anything].
When it's called after setup is complete and writing is enabled; this is the way it's supposed to be used. The current log is closed and the pending log is opened.
public void setupIsComplete()
setupIsComplete
in interface TraceMessageAcceptor
private void shutdownAndSwap()
Before the old log is closed, a USAGE message is logged, directing the reader to the new log. Trace messages may be queued while the swap is happening, but the queue is drained before the method returns.
This routine can be called to backup a full logfile, or to explicitly reopen the same logfile (via TraceLog_reopen=true).
private final void startQueuing()
It is harmless to call this routine twice.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |