|
||||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.javagroups.log.Tracer
Provides output services for a module. Formats messages by adding a
timestamp, the trace level, and the module name. Sends formatted
messages to the file, stream, writer, or socket associated with an
instance of a concrete subclass of Tracer
. Checks trace
level and does not send messages if the specified level is less than
the trace level set by a call to Trace.setOutput
.
Trace
Field Summary | |
---|---|
protected boolean |
autoFlush
If true , every call to print will call
flush . |
protected boolean |
closed
If true , this tracer has been closed and no further output
will be accepted. |
protected int |
level
The current output trace level. |
protected java.lang.String |
module
The module name with which this tracer is associated. |
protected static java.lang.String |
timestampFormat
Set by Trace.setTimestampFormat() and used in the
timestamp method. |
Method Summary | |
---|---|
void |
close()
Flushes any pending output (by calling flush ) and closes
the output file, stream, writer, or socket associated with this tracer. |
protected abstract void |
doClose()
Flushes any pending output (by calling flush ) and closes
the output file, stream, writer, or socket associated with this tracer. |
protected abstract void |
doFlush()
Flushes any pending output. |
protected abstract void |
doPrint(java.lang.String message)
Sends the already-formatted message to the output file,
stream, writer, or socket associated with this tracer. |
void |
flush()
Flushes any pending output. |
boolean |
getAutoFlush()
Returns true if this tracer performs auto-flushing after
every print. |
int |
getLevel()
Returns the current trace level. |
java.lang.String |
getModule()
Returns the module name with which this tracer is associated. |
protected java.lang.String |
logString(java.lang.String module,
int level,
java.lang.String message)
Creates a formatted string suitable for output. |
protected java.lang.String |
logString(java.lang.String module,
int level,
java.lang.String identifier,
java.lang.String message)
|
void |
print(java.lang.String module,
int level,
java.lang.String message)
Sends a formatted string to the output file, stream, writer, or socket. |
void |
print(java.lang.String module,
int level,
java.lang.String identifier,
java.lang.String message)
|
void |
setAutoFlush(boolean autoFlush)
Sets the auto-flush flag. |
void |
setLevel(int level)
Sets the trace level. |
static void |
setTimestampFormat(java.lang.String format)
Set the timestamp format. |
protected java.lang.String |
timestamp()
Returns a timestamp string. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static java.lang.String timestampFormat
Trace.setTimestampFormat()
and used in the
timestamp
method. When null
, the default
format of ISO 8601 is used.
Trace.setTimestampFormat(java.lang.String)
,
Format.formatTimestamp(java.util.Date)
protected java.lang.String module
protected int level
protected boolean autoFlush
true
, every call to print
will call
flush
. Initially false
.
protected boolean closed
true
, this tracer has been closed and no further output
will be accepted.
Method Detail |
public static void setTimestampFormat(java.lang.String format)
format
string is that used by SimpleDateFormat
. If
format
is null
, then the ISO 8601 date
format ("CCYY-MM-DDThh:mm:ss,s") is used.
public java.lang.String getModule()
public int getLevel()
public void setLevel(int level)
level
are output. All others are ignored.
level
- the trace levelpublic boolean getAutoFlush()
true
if this tracer performs auto-flushing after
every print.
true
if this tracer performs auto-flushingpublic void setAutoFlush(boolean autoFlush)
true
, every call to
print
will also call flush
.
autoFlush
- if true
, auto-flushing is turned onpublic void print(java.lang.String module, int level, java.lang.String message)
level
is less than the current trace level, the message
is ignored. If autoFlush
is true
, calls
flush
.
Calls the abstract method doPrint
, which is overridden by
concrete subclasses to perform the actual output.
module
- a module namelevel
- a trace levelmessage
- the string to be outputpublic void print(java.lang.String module, int level, java.lang.String identifier, java.lang.String message)
public void flush()
public void close()
flush
) and closes
the output file, stream, writer, or socket associated with this tracer.
After this method has been called, all calls to print
,
flush
, and close
are ignored.
protected java.lang.String logString(java.lang.String module, int level, java.lang.String message)
module
- a module namelevel
- a trace levelmessage
- the message to be included
protected java.lang.String logString(java.lang.String module, int level, java.lang.String identifier, java.lang.String message)
protected java.lang.String timestamp()
protected abstract void doPrint(java.lang.String message)
message
to the output file,
stream, writer, or socket associated with this tracer.
message
- a formatted stringprotected abstract void doFlush()
flush
, but only
if not alread closed.
protected abstract void doClose()
flush
) and closes
the output file, stream, writer, or socket associated with this tracer.
Called from close
, but only if not alread closed.
After closed has been called, all calls to print
,
flush
, and close
are ignored.
|
||||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |