public class MTrace
extends java.lang.Object
MTrace
class sets up and maintains a trace mapping table,
the data structure that holds the mapping between a message and
the corresponding list of message destinations (sinks). Messages
are defined by role. Four predefined roles are available and
listed below. These roles are accessed when you call the
debug(String, MTrackingInfo)
method in this class.
The MTrace
class provides methods that allow applications to send
traces to a sink. A sink can be a file, a TIBCO Rendezvous session,
or some other application-defined destination. Each trace contains
a time stamp, the trace name, and the user-defined trace message.
The MTrace
and MSink
classes, taken together,
offer the services of printf()
style formatting a message string and sending it to a file, standard
output or publishing it as a TIB/Rendezvous message.
The general idea behind trace and sink is that you
instantiate an MTrace
object, and one or more MSink
-derived
objects. You then map the sinks to the trace object via a
role. The role is any string providing a name to a specific
mapping between a sink object and the trace object.
Once the mapping has thus been created, any string messages sent
to the MTrace
object via trace(Throwable, MTrackingInfo)
method are automatically
logged to the registered sink(s).
The MTrace
and MSink
classes provide the following facilities.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEBUG
Standard role name "debugRole"
|
static java.lang.String |
ERROR
Standard role name "errorRole"
|
static java.lang.String |
INFO
Standard role name "infoRole"
|
static MTrace |
s_sdkTrace
Note - unsupported
|
static java.lang.String |
SDK_MSG_TRACE
Note - unsupported
|
static java.lang.String |
SDK_TRACE
Note - unsupported
|
static java.lang.String |
STACK_TRACE
Note - unsupported
|
static java.lang.String |
WARN
Standard role name "warnRole"
|
Constructor and Description |
---|
MTrace()
Create an instance of
MTrace |
MTrace(java.lang.String msgPrefix)
Create an instance of
MTrace . |
Modifier and Type | Method and Description |
---|---|
void |
addMapping(java.lang.String roleName,
MSink sink)
Map a trace to the specified sink for the specified role.
|
void |
customTrace(java.lang.String errorCode,
MTrackingInfo rTrackingData,
java.lang.String errMsg)
Deprecated.
internal use only - do not document
This replaced trace(String errorCode, MTrackingInfo rTrackingData, String errMsg)
|
void |
customTrace(java.lang.String msgCode,
java.lang.String roleName,
java.lang.String category,
MTrackingInfo trackingInfo,
java.lang.String message)
Deprecated.
internal use only - do not document
|
void |
debug(MTree tree)
Deprecated.
|
void |
debug(java.lang.String msg)
Deprecated.
|
void |
debug(java.lang.String message,
MTrackingInfo trackingInfo)
Send a message to the debug role.
|
void |
debug(java.lang.String customRole,
java.lang.String message,
MTrackingInfo trackingInfo)
Send messages to arbitrary roles.
|
void |
debug(java.lang.String customRole,
java.lang.String category,
java.lang.String message,
MTrackingInfo trackingInfo)
Note - unsupported
|
void |
disable()
Disable all roles to write to their respective sinks
|
void |
disable(java.lang.String roleName)
Disable the specified role to write to its sinks.
|
void |
enable()
Enable all tracing.
|
void |
enable(java.lang.String roleName)
Enable the specified role to write to its sinks.
|
void |
error(MTree tree)
Deprecated.
|
void |
error(java.lang.String msg)
Deprecated.
|
static MTrace |
getDefaultTrace()
Return the first
MTrace that was created if there
is one, otherwise, creates a new MTrace instance as the default MTrace . |
java.lang.String |
getMsgPrefix()
Note - unsupported
|
int |
getNewErrosSinceLastCall() |
MRole |
getRole(java.lang.String roleName)
Note - unsupported
|
java.util.Enumeration |
getRoles()
Return all roles known to this trace.
|
MSink |
getSink(java.lang.String sinkName)
Note - unsupported
|
java.util.Enumeration |
getSinks()
Enumerates through all distinct sinks of all roles.
|
java.util.Enumeration |
getSinks(java.lang.String roleName)
Return the sinks associated with this role.
|
java.lang.String |
getTimeStamp()
Deprecated.
internal use only - do not document
|
int |
getTotalErros() |
static boolean |
hasDefaultTrace()
Note - unsupported
|
void |
incrementError() |
void |
info(MTree tree)
Deprecated.
|
void |
info(java.lang.String msg)
Deprecated.
|
boolean |
isRoleActive(java.lang.String roleName)
Note - unsupported
|
void |
printThreadName()
Note - unsupported
|
void |
removeMapping(java.lang.String roleName,
java.lang.String sinkName)
Disassociate the sink with the given name from the specified role.
|
void |
sdkMsgTrace(java.lang.String msg)
Note - unsupported
|
void |
sdkTrace(MTree tree)
Note - unsupported
|
void |
sdkTrace(java.lang.String msg)
Note - unsupported
|
static void |
setDefaultTrace(MTrace defMTrace)
Note - unsupported
|
void |
setMsgPrefix(java.lang.String msgPrefix)
Deprecated.
internal use only - do not document
|
void |
setTimeStampFormat(java.lang.String timeStampFormat)
Deprecated.
internal use only - do not document
|
void |
stackTrace(java.lang.Throwable ex)
Note - unsupported
|
void |
trace(java.lang.String errorCode,
MTrackingInfo trackingData)
Output a message to all sinks associated with this role.
|
void |
trace(java.lang.String code,
MTrackingInfo trackingData,
java.lang.Object param1)
Send tracing information to all sinks.
|
void |
trace(java.lang.String code,
MTrackingInfo trackingData,
java.lang.Object[] params) |
void |
trace(java.lang.String code,
MTrackingInfo trackingData,
java.lang.Object param1,
java.lang.Object param2) |
void |
trace(java.lang.String code,
MTrackingInfo trackingData,
java.lang.Object param1,
java.lang.Object param2,
java.lang.Object param3) |
void |
trace(java.lang.String code,
MTrackingInfo trackingData,
java.lang.Object param1,
java.lang.Object param2,
java.lang.Object param3,
java.lang.Object param4) |
void |
trace(java.lang.String code,
MTrackingInfo trackingData,
java.lang.Object param1,
java.lang.Object param2,
java.lang.Object param3,
java.lang.Object param4,
java.lang.Object param5) |
void |
trace(java.lang.String code,
MTrackingInfo trackingData,
java.lang.Object param1,
java.lang.Object param2,
java.lang.Object param3,
java.lang.Object param4,
java.lang.Object param5,
java.lang.Object param6) |
void |
trace(java.lang.String code,
MTrackingInfo trackingData,
java.lang.Object param1,
java.lang.Object param2,
java.lang.Object param3,
java.lang.Object param4,
java.lang.Object param5,
java.lang.Object param6,
java.lang.Object param7) |
void |
trace(java.lang.String code,
MTrackingInfo trackingData,
java.lang.Object param1,
java.lang.Object param2,
java.lang.Object param3,
java.lang.Object param4,
java.lang.Object param5,
java.lang.Object param6,
java.lang.Object param7,
java.lang.Object param8) |
void |
trace(java.lang.String errorCode,
MTrackingInfo rTrackingData,
java.lang.String errMsg)
Deprecated.
|
void |
trace(java.lang.String roleName,
MTree tree)
Deprecated.
|
void |
trace(java.lang.String roleName,
java.lang.String msg)
Deprecated.
|
void |
trace(java.lang.String roleName,
java.lang.Throwable ex)
Deprecated.
|
void |
trace(java.lang.String code,
java.lang.Throwable ex,
MTrackingInfo trackingData)
Output a message to all sinks associated with this role.
|
void |
trace(java.lang.Throwable ex,
MTrackingInfo trackingData)
Send tracing information to all sinks.
|
void |
warn(MTree tree)
Deprecated.
|
void |
warn(java.lang.String msg)
Deprecated.
|
public static MTrace s_sdkTrace
public static final java.lang.String ERROR
public static final java.lang.String WARN
public static final java.lang.String INFO
public static final java.lang.String DEBUG
public static final java.lang.String SDK_TRACE
public static final java.lang.String STACK_TRACE
public static final java.lang.String SDK_MSG_TRACE
public MTrace(java.lang.String msgPrefix)
MTrace
.
Call getDefaultTrace()
to have the system return the first trace
created, or create a new one if none exists.msgPrefix
- This prefix is added to all messages coming from this trace.public MTrace()
MTrace
MTrace(String)
public static MTrace getDefaultTrace()
MTrace
that was created if there
is one, otherwise, creates a new MTrace
instance as the default MTrace
.public void addMapping(java.lang.String roleName, MSink sink)
If you want trace messages of all roles to arrive at the sink,
call addMapping()
multiple times. You can send different
types of messages to different sinks or to the same sink.
Even if you add the same sink several times, the trace messages are logged only once.
The SDK provides four predefined roles:
Applications can also predefine their own roles and use any role name they like.public void removeMapping(java.lang.String roleName, java.lang.String sinkName)
After calling this method, the sink with the specified role and sink name no longer serves as a sink for this trace.
roleName
- One of ERROR
, WARN
,
INFO
, DEBUG
,
or an application-defined role.sinkName
- Name of the sink that you want to disassociate from this trace.addMapping(String, MSink)
public void disable()
public void disable(java.lang.String roleName)
public void enable()
public void enable(java.lang.String roleName)
public java.util.Enumeration getRoles()
Enumeration
can be cast to MRole
.public java.util.Enumeration getSinks(java.lang.String roleName)
Enumeration.nextElement()
can be canst to MRole
.public java.util.Enumeration getSinks()
The object returned from Enumeration.nextElement()
can be cast to MSink
.
public void debug(java.lang.String message, MTrackingInfo trackingInfo)
This method provides a means for tracing (that is, auditing) significant steps. The SDK uses the specified message string for the trace message.
message
- Message to send to all sinks with debug role.trackingInfo
- If this argument value is null, it is ignored.
The information contained in the MTrackingInfo
instance identified
by this argument is traced to the relevant sinks.
For further information on message format, see "Trace Message Format" in TIBCO Adapter SDK Concepts.
trace(String, Throwable, MTrackingInfo)
,
MTrackingInfo
public void debug(java.lang.String customRole, java.lang.String message, MTrackingInfo trackingInfo)
customRole
- This argument is used to send messages to arbitrary roles.message
- Message to send to all sinks with debug role.trackingInfo
- If this argument value is null, it is ignored.
The information contained in the MTrackingInfo
instance identified
by this argument is traced to the relevant sinks.debug(String, MTrackingInfo)
public void trace(java.lang.String code, java.lang.Throwable ex, MTrackingInfo trackingData)
code
- The unique code of an error, info, warn or debug message.ex
- Exception to send to trace.trackingData
- Tracking information to send to trace.public void trace(java.lang.Throwable ex, MTrackingInfo trackingData)
ex
- Exception (MException
or MRuntimeException
to send to trace.trackingData
- Tracking information to send to trace.debug(String, MTrackingInfo)
public void trace(java.lang.String errorCode, MTrackingInfo trackingData)
public void trace(java.lang.String code, MTrackingInfo trackingData, java.lang.Object param1)
code
- The unique code of an error, info, warn, or debug message.trackingData
- Tracking information to send to trace.param1
- Substitution variable to be replaced within the message.
For each paramn
, this specifies the substitution
variables to be replaced within the message.public void trace(java.lang.String code, MTrackingInfo trackingData, java.lang.Object param1, java.lang.Object param2)
trace(String, MTrackingInfo, Object)
public void trace(java.lang.String code, MTrackingInfo trackingData, java.lang.Object param1, java.lang.Object param2, java.lang.Object param3)
trace(String, MTrackingInfo, Object)
public void trace(java.lang.String code, MTrackingInfo trackingData, java.lang.Object param1, java.lang.Object param2, java.lang.Object param3, java.lang.Object param4)
trace(String, MTrackingInfo, Object)
public void trace(java.lang.String code, MTrackingInfo trackingData, java.lang.Object param1, java.lang.Object param2, java.lang.Object param3, java.lang.Object param4, java.lang.Object param5)
trace(String, MTrackingInfo, Object)
public void trace(java.lang.String code, MTrackingInfo trackingData, java.lang.Object param1, java.lang.Object param2, java.lang.Object param3, java.lang.Object param4, java.lang.Object param5, java.lang.Object param6)
trace(String, MTrackingInfo, Object)
public void trace(java.lang.String code, MTrackingInfo trackingData, java.lang.Object param1, java.lang.Object param2, java.lang.Object param3, java.lang.Object param4, java.lang.Object param5, java.lang.Object param6, java.lang.Object param7)
trace(String, MTrackingInfo, Object)
public void trace(java.lang.String code, MTrackingInfo trackingData, java.lang.Object param1, java.lang.Object param2, java.lang.Object param3, java.lang.Object param4, java.lang.Object param5, java.lang.Object param6, java.lang.Object param7, java.lang.Object param8)
trace(String, MTrackingInfo, Object)
public void trace(java.lang.String code, MTrackingInfo trackingData, java.lang.Object[] params)
trace(String, MTrackingInfo, Object)
public void debug(java.lang.String customRole, java.lang.String category, java.lang.String message, MTrackingInfo trackingInfo)
public boolean isRoleActive(java.lang.String roleName)
public static void setDefaultTrace(MTrace defMTrace)
public MSink getSink(java.lang.String sinkName)
public MRole getRole(java.lang.String roleName)
public java.lang.String getTimeStamp()
public void trace(java.lang.String roleName, java.lang.String msg)
public void trace(java.lang.String roleName, java.lang.Throwable ex)
public void customTrace(java.lang.String msgCode, java.lang.String roleName, java.lang.String category, MTrackingInfo trackingInfo, java.lang.String message)
public void customTrace(java.lang.String errorCode, MTrackingInfo rTrackingData, java.lang.String errMsg)
public void trace(java.lang.String errorCode, MTrackingInfo rTrackingData, java.lang.String errMsg)
public void error(java.lang.String msg)
public void warn(java.lang.String msg)
public void info(java.lang.String msg)
public void debug(java.lang.String msg)
public void sdkTrace(java.lang.String msg)
public void stackTrace(java.lang.Throwable ex)
public void sdkMsgTrace(java.lang.String msg)
public void sdkTrace(MTree tree)
public void trace(java.lang.String roleName, MTree tree)
public void error(MTree tree)
public void warn(MTree tree)
public void info(MTree tree)
public void debug(MTree tree)
public java.lang.String getMsgPrefix()
public void setMsgPrefix(java.lang.String msgPrefix)
public void setTimeStampFormat(java.lang.String timeStampFormat)
public void printThreadName()
public void incrementError()
public int getTotalErros()
public int getNewErrosSinceLastCall()
public static boolean hasDefaultTrace()