public class Trace extends Object
A collection of trace priority thresholds, represented by a group of boolean variables, control which trace messages are actually output. These variables can be tested by a user of the trace code to quickly decide whether to call a trace method (thus helping avoid the costs of procedure call and string manipulation in cases where no output would be generated anyway).
Modifier and Type | Field and Description |
---|---|
static Trace |
comm
Trace object for the 'comm' (communications) subsystem.
|
boolean |
debug
Flag to control tracing of debug messages.
|
static int |
DEBUG
"Debug" level trace threshold
|
boolean |
error
Flag to control tracing of error messages.
|
static int |
ERROR
"Error" level trace threshold
|
boolean |
event
Flag to control tracing of event messages.
|
static int |
EVENT
"Event" level trace threshold
|
static int |
MESSAGE
"Message" level trace threshold.
|
static int |
METRICS
"Metrics" level (not thresholded)
|
static Trace |
none
Trace object for the 'none' subsystem.
|
static int |
NOTICE
"Notice" level (not thresholded)
|
static boolean |
ON
This variable statically controls whether tracing is enabled at all.
|
static Trace |
runq
Trace object for the 'runq' (run queue) subsystem.
|
static Trace |
startup
Trace object for the 'startup' subsystem.
|
static Trace |
timers
Trace object for the 'timers' subsystem.
|
static Trace |
trace
Trace object for the 'trace' subsystem itself.
|
boolean |
usage
Flag to control tracing of usage messages.
|
static int |
USAGE
"Usage" level trace threshold
|
boolean |
verbose
Flag to control tracing of verbose messages.
|
static int |
VERBOSE
"Verbose" level trace threshold
|
boolean |
warning
Flag to control tracing of warning messages.
|
static int |
WARNING
"Warning" level trace threshold
|
boolean |
world
Flag to control tracing of world messages.
|
static int |
WORLD
"World" level trace threshold
|
Modifier and Type | Method and Description |
---|---|
static String |
byteArrayToASCII(byte[] buf,
int offset,
int length)
Convert an array of bytes into a string suitable for output to a log.
|
void |
debugi(String message)
Output an informational log message at DEBUG level.
|
void |
debugm(String message)
Output a log message at DEBUG level.
|
void |
debugm(String message,
Object obj)
Output a log message at DEBUG level, with attached object.
|
void |
debugReportException(Throwable th,
String message)
Log an exception event at DEBUG level.
|
void |
errori(String message)
Output an informational log message at ERROR level.
|
void |
errorm(String message)
Output a log message at ERROR level.
|
void |
errorm(String message,
Object obj)
Output a log message at ERROR level, with attached object.
|
void |
errorReportException(Throwable th,
String message)
Log an exception event at ERROR level.
|
void |
eventi(String message)
Output an informational log message at EVENT level.
|
void |
eventm(String message)
Output a log message at EVENT level.
|
void |
eventm(String message,
Object obj)
Output a log message at EVENT level, with attached object.
|
void |
eventReportException(Throwable th,
String message)
Log an exception event at EVENT level.
|
void |
fatalError(String message)
Exit reporting a fatal error.
|
void |
fatalError(String message,
Object obj)
Exit reporting a fatal error, with attached object (usually but not
necessarily a
Throwable of some kind). |
void |
metrics(String type,
int id)
Output an unvalued metrics message.
|
void |
metrics(String type,
int id,
boolean value)
Output a boolean-valued metrics message.
|
void |
metrics(String type,
int id,
double value)
Output a floating point-valued metrics message.
|
void |
metrics(String type,
int id,
int value)
Output an integer-valued metrics message.
|
void |
metrics(String type,
int id,
JSONLiteral value)
Output a JSON object-valued metrics message.
|
void |
metrics(String type,
int id,
JSONObject value)
Output a JSON object-valued metrics message.
|
void |
metrics(String type,
int id,
long value)
Output a long-valued metrics message.
|
void |
metrics(String type,
int id,
String value)
Output a string-valued metrics message.
|
void |
msgi(Object conn,
boolean inbound,
Object msg)
Output a log message describing a comm message.
|
void |
noticei(String message)
Output an informational log message at NOTICE level (which is
unblockable).
|
void |
setThreshold(int threshold)
Set the logging threshold.
|
void |
shred(Throwable ex,
String reason)
Record a
Throwable along with a trace message. |
Trace |
subTrace(String subSubsystem)
Obtain a Trace object based on another Trace object.
|
static Trace |
trace(String subsystem)
Obtain the Trace object for a given subsystem.
|
void |
usagei(String message)
Output an informational log message at USAGE level.
|
void |
usagem(String message)
Output a log message at USAGE level.
|
void |
usagem(String message,
Object obj)
Output a log message at USAGE level, with attached object.
|
void |
usageReportException(Throwable th,
String message)
Log an exception event at USAGE level.
|
void |
verbosei(String message)
Output an informational log message at VERBOSE level.
|
void |
verbosem(String message)
Output a log message at VERBOSE level.
|
void |
verbosem(String message,
Object obj)
Output a log message at VERBOSE level, with attached object.
|
void |
verboseReportException(Throwable th,
String message)
Log an exception event at VERBOSE level.
|
void |
warningi(String message)
Output an informational log message at WARNING level.
|
void |
warningm(String message)
Output a log message at WARNING level.
|
void |
warningm(String message,
Object obj)
Output a log message at WARNING level, with attached object.
|
void |
warningReportException(Throwable th,
String message)
Log an exception event at WARNING level.
|
void |
worldi(String message)
Output an informational log message at WORLD level.
|
void |
worldm(String message)
Output a log message at WORLD level.
|
void |
worldm(String message,
Object obj)
Output a log message at WORLD level, with attached object.
|
void |
worldReportException(Throwable th,
String message)
Log an exception event at WORLD level.
|
public static final int NOTICE
public static final int METRICS
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 MESSAGE
public static final int DEBUG
public static final int VERBOSE
public static final boolean ON
public boolean error
public boolean warning
public boolean world
public boolean usage
public boolean event
public boolean debug
public boolean verbose
public static Trace comm
public static Trace none
public static Trace runq
public static Trace startup
public static Trace timers
public static Trace trace
public static Trace trace(String subsystem)
subsystem
- The name of the subsystem of interest.public Trace subTrace(String subSubsystem)
subSubsystem
- A name tag that will be appended to this trace
object's subsystem name.public void setThreshold(int threshold)
threshold
- The new threshold value.public static String byteArrayToASCII(byte[] buf, int offset, int length)
buf
- Byte array containing data to be converted.offset
- Index of start position to convert.length
- Number of bytes to convert.public void fatalError(String message)
message
- The error message to die with.public void fatalError(String message, Object obj)
Throwable
of some kind).message
- The error message to die with.obj
- Object to report with message.public void shred(Throwable ex, String reason)
Throwable
along with a trace message.To ensure that exceptional conditions are only being ignored for good reason, we adopt the discipline that a caught exception should:
1) be rethrown
2) cause another exception to be thrown instead
3) be ignored, in a traceable way, for some stated reason
Only by making #3 explicit can we distinguish it from accidentally
ignoring the exception. An exception should, therefore, only be ignored
by asking a Trace
object to shred it. This request carries a
string that justifies allowing the program to continue normally
following this event. As shredded exceptions may be symptoms of bugs,
this will enable them to be traced.
The reason for the shredding is logged at verbose level.
ex
- The exception to shred.reason
- A string justifying this.public void metrics(String type, int id, String value)
type
- Type tagid
- Session id number to associate with the message.value
- The value to record.public void metrics(String type, int id, int value)
type
- Type tagid
- Session id number to associate with the message.value
- The value to record.public void metrics(String type, int id, long value)
type
- Type tagid
- Session id number to associate with the message.value
- The value to record.public void metrics(String type, int id, double value)
type
- Type tagid
- Session id number to associate with the message.value
- The value to record.public void metrics(String type, int id)
type
- Type tagid
- Session id number to associate with the message.public void metrics(String type, int id, boolean value)
type
- Type tagid
- Session id number to associate with the message.value
- The value to record.public void metrics(String type, int id, JSONLiteral value)
type
- Type tagid
- Session id number to associate with the message.value
- The value to record.public void metrics(String type, int id, JSONObject value)
type
- Type tagid
- Session id number to associate with the message.value
- The value to record.public void noticei(String message)
message
- The message stringpublic void msgi(Object conn, boolean inbound, Object msg)
conn
- The connection over which the message was sent or received.inbound
- True if the message was received, false if it was sentmsg
- The message itself that is to be loggedpublic void debugi(String message)
message
- The message to write to the log.public void debugm(String message)
message
- The message to write to the log.public void debugm(String message, Object obj)
message
- The message to write to the log.obj
- Object to report with message.public void debugReportException(Throwable th, String message)
th
- The exception to logmessage
- An explanatory message to accompany the log entry.public void errori(String message)
message
- The message to write to the log.public void errorm(String message)
message
- The message to write to the log.public void errorm(String message, Object obj)
message
- The message to write to the log.obj
- Object to report with message.public void errorReportException(Throwable th, String message)
th
- The exception to logmessage
- An explanatory message to accompany the log entry.public void eventi(String message)
message
- The message to write to the log.public void eventm(String message)
message
- The message to write to the log.public void eventm(String message, Object obj)
message
- The message to write to the log.obj
- Object to report with message.public void eventReportException(Throwable th, String message)
th
- The exception to logmessage
- An explanatory message to accompany the log entry.public void usagei(String message)
message
- The message to write to the log.public void usagem(String message)
message
- The message to write to the log.public void usagem(String message, Object obj)
message
- The message to write to the log.obj
- Object to report with message.public void usageReportException(Throwable th, String message)
th
- The exception to logmessage
- An explanatory message to accompany the log entry.public void verbosei(String message)
message
- The message to write to the log.public void verbosem(String message)
message
- The message to write to the log.public void verbosem(String message, Object obj)
message
- The message to write to the log.obj
- Object to report with message.public void verboseReportException(Throwable th, String message)
th
- The exception to logmessage
- An explanatory message to accompany the log entry.public void warningi(String message)
message
- The message to write to the log.public void warningm(String message)
message
- The message to write to the log.public void warningm(String message, Object obj)
message
- The message to write to the log.obj
- Object to report with message.public void warningReportException(Throwable th, String message)
th
- The exception to logmessage
- An explanatory message to accompany the log entry.public void worldi(String message)
message
- The message to write to the log.public void worldm(String message)
message
- The message to write to the log.public void worldm(String message, Object obj)
message
- The message to write to the log.obj
- Object to report with message.Copyright © 2017. All rights reserved.