Package trclib.robotcore
Class TrcDbgTrace
java.lang.Object
trclib.robotcore.TrcDbgTrace
This class implements the Debug Tracer.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
This interface provides a platform independent way to write to the debug log.static enum
This enum specifies the different debug message levels. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static TrcDbgTrace.DbgLog
private static TrcDbgTrace
private static final String
private TrcDbgTrace.MsgLevel
private static TrcTraceLogger
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor: Create an instance of the object.TrcDbgTrace
(String callerName, TrcDbgTrace.DbgLog dbgLog) Constructor: Create an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
This method closes the trace log file.static TrcDbgTrace
This method returns a global debug trace object for tracing OpMode code.This method returns the trace message level.static String
This method returns the trace log file name if one is active.static void
globalTraceDebug
(String callerInstance, String text) This method is called to print a debug message using the global tracer.static void
globalTraceDebug
(String callerInstance, String format, Object... args) This method is called to print a debug message using the global tracer.static void
globalTraceErr
(String callerInstance, String text) This method is called to print an error message using the global tracer.static void
globalTraceErr
(String callerInstance, String format, Object... args) This method is called to print an error message using the global tracer.static void
globalTraceFatal
(String callerInstance, String text) This method is called to print a fatal message using the global tracer.static void
globalTraceFatal
(String callerInstance, String format, Object... args) This method is called to print a fatal message using the global tracer.static void
globalTraceInfo
(String callerInstance, String text) This method is called to print an information message using the global tracer.static void
globalTraceInfo
(String callerInstance, String format, Object... args) This method is called to print an information message using the global tracer.static void
globalTraceVerbose
(String callerInstance, String text) This method is called to print a verbose message using the global tracer.static void
globalTraceVerbose
(String callerInstance, String format, Object... args) This method is called to print a verbose message using the global tracer.static void
globalTraceWarn
(String callerInstance, String text) This method is called to print a warning message using the global tracer.static void
globalTraceWarn
(String callerInstance, String format, Object... args) This method is called to print a warning message using the global tracer.boolean
This method checks if the specified msgLevel is enabled.static boolean
This method checks if the trace log is enabled.static boolean
This method checks if the trace log is opened.void
This method logs a MsgLevel.INFO entry that contains an event.void
This method logs a MsgLevel.INFO entry that contains an event.private void
logEventInternal
(String callerInstance, int methodIndex, String eventName, String text) This method logs a MsgLevel.INFO entry that contains an event.void
This method logs a MsgLevel.INFO entry that contains information about the match.void
This method logs a MsgLevel.INFO entry that contains information about the match.static boolean
openTraceLog
(String traceLogName) This method opens a log file for writing all the trace messages to it.static boolean
openTraceLog
(String folderPath, String fileName) This method opens a log file for writing all the trace messages to it.static void
This method prints the exception stack to the global tracer.static void
This method prints the stack of the current thread to the trace log.static void
printThreadStack
(Thread thread) This method prints the stack of the given thread to the trace log.void
setTraceLevel
(TrcDbgTrace.MsgLevel msgLevel) This method sets the message level for this tracer.static void
setTraceLogEnabled
(boolean enabled) This method enables/disables the trace log.void
traceDebug
(String callerInstance, String text) This method is called to print a debug message.void
traceDebug
(String callerInstance, String format, Object... args) This method is called to print a debug message.void
This method is called to print an error message.void
This method is called to print an error message.void
traceFatal
(String callerInstance, String text) This method is called to print a fatal message.void
traceFatal
(String callerInstance, String format, Object... args) This method is called to print a fatal message.void
This method is called to print an information message.void
This method is called to print an information message.private void
traceMsgWorker
(String callerInstance, int methodIndex, TrcDbgTrace.MsgLevel level, String text) This method is the common worker for all the trace message methods.void
tracePostStateInfo
(String name, Object state, TrcDriveBase driveBase, TrcPidDrive pidDrive) This method logs a post-state info event using the global tracer.void
tracePostStateInfo
(String name, Object state, TrcDriveBase driveBase, TrcPidDrive pidDrive, TrcPurePursuitDrive ppDrive, TrcRobotBattery battery) This method logs a post-state info event using the global tracer.void
tracePostStateInfo
(String name, Object state, TrcDriveBase driveBase, TrcPurePursuitDrive ppDrive) This method logs a post-state info event using the global tracer.void
tracePostStateInfo
(String name, Object state, TrcRobotBattery battery) This method logs a post-state info event using the global tracer.private void
tracePostStateInfoWorker
(String name, Object state, TrcDriveBase driveBase, TrcPidDrive pidDrive, TrcPurePursuitDrive ppDrive, TrcRobotBattery battery) This method logs a post-state info event using the global tracer.void
tracePreStateInfo
(String name, Object state) This method logs a pre-state info event using the global tracer.void
traceVerbose
(String callerInstance, String text) This method is called to print a verbose message.void
traceVerbose
(String callerInstance, String format, Object... args) This method is called to print a verbose message.void
This method is called to print a warning message.void
This method is called to print a warning message.
-
Field Details
-
moduleName
-
dbgLog
-
globalTracer
-
traceLogger
-
msgLevel
-
-
Constructor Details
-
TrcDbgTrace
Constructor: Create an instance of the object. This constructor is intended for internal use for creating the global tracer. For creating other tracers, use the constructor with just instanceName.- Parameters:
callerName
- specifies the module name of the caller.dbgLog
- specifies the dbgLog object to be set.
-
TrcDbgTrace
public TrcDbgTrace()Constructor: Create an instance of the object.
-
-
Method Details
-
setTraceLevel
This method sets the message level for this tracer.- Parameters:
msgLevel
- specifies the message level.
-
getTraceLevel
This method returns the trace message level.- Returns:
- trace message level.
-
getGlobalTracer
This method returns a global debug trace object for tracing OpMode code. If it doesn't exist yet, one is created. This is an easy way to quickly get some debug output without a whole lot of setup overhead as the full module-based debug tracing.- Returns:
- global opMode trace object.
-
openTraceLog
This method opens a log file for writing all the trace messages to it.- Parameters:
traceLogName
- specifies the full trace log file path name.- Returns:
- true if log file is successfully opened, false if it failed.
-
openTraceLog
This method opens a log file for writing all the trace messages to it. The log file is written to the specified folder. The file name will be formed by concatenating the date-time stamp with the specified file name.- Parameters:
folderPath
- specifies the folder path.fileName
- specifies the file name, null if none provided.- Returns:
- true if log file is successfully opened, false if it failed.
-
closeTraceLog
public static void closeTraceLog()This method closes the trace log file. -
isTraceLogOpened
public static boolean isTraceLogOpened()This method checks if the trace log is opened.- Returns:
- true if trace log is opened, false otherwise.
-
getTraceLogName
This method returns the trace log file name if one is active.- Returns:
- trace log file name if one is active, null if none.
-
setTraceLogEnabled
public static void setTraceLogEnabled(boolean enabled) This method enables/disables the trace log.- Parameters:
enabled
- specifies true to enable trace log, false otherwise.
-
isTraceLogEnabled
public static boolean isTraceLogEnabled()This method checks if the trace log is enabled.- Returns:
- true if trace log is enabled, false if disabled.
-
printExceptionStack
This method prints the exception stack to the global tracer.- Parameters:
e
- specifies the exception.
-
printThreadStack
This method prints the stack of the given thread to the trace log.- Parameters:
thread
- specifies the thread to print its stack.
-
printThreadStack
public static void printThreadStack()This method prints the stack of the current thread to the trace log. -
isMsgLevelEnabled
This method checks if the specified msgLevel is enabled.- Parameters:
level
- specifies the msgLevel.- Returns:
- true if enabled, false otherwise.
-
traceMsgWorker
private void traceMsgWorker(String callerInstance, int methodIndex, TrcDbgTrace.MsgLevel level, String text) This method is the common worker for all the trace message methods.- Parameters:
callerInstance
- specifies the name to identify the caller.methodIndex
- specifies the index to the thread stack to obtain the method name.level
- specifies the message level.text
- specifies the message text.
-
traceFatal
This method is called to print a fatal message.- Parameters:
callerInstance
- specifies the name to identify the caller.text
- specifies the message text.
-
traceFatal
This method is called to print a fatal message.- Parameters:
callerInstance
- specifies the name to identify the caller.format
- specifies the format string of the message.args
- specifies the message arguments.
-
traceErr
This method is called to print an error message.- Parameters:
callerInstance
- specifies the name to identify the caller.text
- specifies the message text.
-
traceErr
This method is called to print an error message.- Parameters:
callerInstance
- specifies the name to identify the caller.format
- specifies the format string of the message.args
- specifies the message arguments.
-
traceWarn
This method is called to print a warning message.- Parameters:
callerInstance
- specifies the name to identify the caller.text
- specifies the message text.
-
traceWarn
This method is called to print a warning message.- Parameters:
callerInstance
- specifies the name to identify the caller.format
- specifies the format string of the message.args
- specifies the message arguments.
-
traceInfo
This method is called to print an information message.- Parameters:
callerInstance
- specifies the name to identify the caller.text
- specifies the message text.
-
traceInfo
This method is called to print an information message.- Parameters:
callerInstance
- specifies the name to identify the caller.format
- specifies the format string of the message.args
- specifies the message arguments.
-
traceDebug
This method is called to print a debug message.- Parameters:
callerInstance
- specifies the name to identify the caller.text
- specifies the message text.
-
traceDebug
This method is called to print a debug message.- Parameters:
callerInstance
- specifies the name to identify the caller.format
- specifies the format string of the message.args
- specifies the message arguments.
-
traceVerbose
This method is called to print a verbose message.- Parameters:
callerInstance
- specifies the name to identify the caller.text
- specifies the message text.
-
traceVerbose
This method is called to print a verbose message.- Parameters:
callerInstance
- specifies the name to identify the caller.format
- specifies the format string of the message.args
- specifies the message arguments.
-
globalTraceFatal
This method is called to print a fatal message using the global tracer.- Parameters:
callerInstance
- specifies the name to identify the caller.text
- specifies the message text.
-
globalTraceFatal
This method is called to print a fatal message using the global tracer.- Parameters:
callerInstance
- specifies the name to identify the caller.format
- specifies the format string of the message.args
- specifies the message arguments.
-
globalTraceErr
This method is called to print an error message using the global tracer.- Parameters:
callerInstance
- specifies the name to identify the caller.text
- specifies the message text.
-
globalTraceErr
This method is called to print an error message using the global tracer.- Parameters:
callerInstance
- specifies the name to identify the caller.format
- specifies the format string of the message.args
- specifies the message arguments.
-
globalTraceWarn
This method is called to print a warning message using the global tracer.- Parameters:
callerInstance
- specifies the name to identify the caller.text
- specifies the message text.
-
globalTraceWarn
This method is called to print a warning message using the global tracer.- Parameters:
callerInstance
- specifies the name to identify the caller.format
- specifies the format string of the message.args
- specifies the message arguments.
-
globalTraceInfo
This method is called to print an information message using the global tracer.- Parameters:
callerInstance
- specifies the name to identify the caller.text
- specifies the message text.
-
globalTraceInfo
This method is called to print an information message using the global tracer.- Parameters:
callerInstance
- specifies the name to identify the caller.format
- specifies the format string of the message.args
- specifies the message arguments.
-
globalTraceDebug
This method is called to print a debug message using the global tracer.- Parameters:
callerInstance
- specifies the name to identify the caller.text
- specifies the message text.
-
globalTraceDebug
This method is called to print a debug message using the global tracer.- Parameters:
callerInstance
- specifies the name to identify the caller.format
- specifies the format string of the message.args
- specifies the message arguments.
-
globalTraceVerbose
This method is called to print a verbose message using the global tracer.- Parameters:
callerInstance
- specifies the name to identify the caller.text
- specifies the message text.
-
globalTraceVerbose
This method is called to print a verbose message using the global tracer.- Parameters:
callerInstance
- specifies the name to identify the caller.format
- specifies the format string of the message.args
- specifies the message arguments.
-
logInfo
This method logs a MsgLevel.INFO entry that contains information about the match. The entry is in XML format and is intended to be parsed by tools such as TrcTraceLogVisualizer.- Parameters:
callerInstance
- specifies the name to identify the caller.infoName
- specifies the name to identify the information.text
- specifies the message text.
-
logInfo
This method logs a MsgLevel.INFO entry that contains information about the match. The entry is in XML format and is intended to be parsed by tools such as TrcTraceLogVisualizer.- Parameters:
callerInstance
- specifies the name to identify the caller.infoName
- specifies the name to identify the information.format
- specifies the format string of the message.args
- specifies the message arguments.
-
logEvent
This method logs a MsgLevel.INFO entry that contains an event. The entry is in XML format and is intended to be parsed by tools such as TrcTraceLogVisualizer.- Parameters:
callerInstance
- specifies the name to identify the caller.eventName
- specifies the name to identify the event.text
- specifies the message text.
-
logEvent
This method logs a MsgLevel.INFO entry that contains an event. The entry is in XML format and is intended to be parsed by tools such as TrcTraceLogVisualizer.- Parameters:
callerInstance
- specifies the name to identify the caller.eventName
- specifies the name to identify the event.format
- specifies the format string of the message.args
- specifies the message arguments.
-
logEventInternal
private void logEventInternal(String callerInstance, int methodIndex, String eventName, String text) This method logs a MsgLevel.INFO entry that contains an event. The entry is in XML format and is intended to be parsed by tools such as TrcTraceLogVisualizer.- Parameters:
callerInstance
- specifies the name to identify the caller.methodIndex
- specifies the index to the thread stack to obtain the method name.eventName
- specifies the name to identify the event.text
- specifies the message text.
-
tracePreStateInfo
This method logs a pre-state info event using the global tracer. The pre-state info event can be used to debug a state machine when the state is about to be executed.- Parameters:
name
- specifies the instance name of the state machine.state
- specifies the current state of the state machine.
-
tracePostStateInfoWorker
private void tracePostStateInfoWorker(String name, Object state, TrcDriveBase driveBase, TrcPidDrive pidDrive, TrcPurePursuitDrive ppDrive, TrcRobotBattery battery) This method logs a post-state info event using the global tracer. The post-state info event can be used to debug a state machine after the state was executed. If the state involves PID controlled driving, it also logs the robot's movement. Post-state info contains information of the async operations it has started but not necessarily finished.- Parameters:
name
- specifies the instance name of the state machine.state
- specifies the current state of the state machine.driveBase
- specifies the robot drive base, can be null if the state does not involve robot movement.pidDrive
- specifies the pidDrive object, can be null if the state does not involve robot movement.ppDrive
- specifies the purePursuitDrive object, can be null if the state does not involve pp drive.battery
- specifies the robot battery object, can be null if not interested in battery info.
-
tracePostStateInfo
public void tracePostStateInfo(String name, Object state, TrcDriveBase driveBase, TrcPidDrive pidDrive, TrcPurePursuitDrive ppDrive, TrcRobotBattery battery) This method logs a post-state info event using the global tracer. The post-state info event can be used to debug a state machine after the state was executed. If the state involves PID controlled driving, it also logs the robot's movement. Post-state info contains information of the async operations it has started but not necessarily finished.- Parameters:
name
- specifies the instance name of the state machine.state
- specifies the current state of the state machine.driveBase
- specifies the robot drive base, can be null if the state does not involve robot movement.pidDrive
- specifies the pidDrive object, can be null if the state does not involve robot movement.ppDrive
- specifies the purePursuitDrive object, can be null if the state does not involve pp drive.battery
- specifies the robot battery object, can be null if not interested in battery info.
-
tracePostStateInfo
public void tracePostStateInfo(String name, Object state, TrcDriveBase driveBase, TrcPidDrive pidDrive) This method logs a post-state info event using the global tracer. The post-state info event can be used to debug a state machine after the state was executed. If the state involves PID controlled driving, it also logs the robot's movement. Post-state info contains information of the async operations it has started but not necessarily finished.- Parameters:
name
- specifies the instance name of the state machine.state
- specifies the current state of the state machine.driveBase
- specifies the robot drive base, can be null if the state does not involve robot movement.pidDrive
- specifies the pidDrive object, can be null if the state does not involve robot movement.
-
tracePostStateInfo
public void tracePostStateInfo(String name, Object state, TrcDriveBase driveBase, TrcPurePursuitDrive ppDrive) This method logs a post-state info event using the global tracer. The post-state info event can be used to debug a state machine after the state was executed. If the state involves PID controlled driving, it also logs the robot's movement. Post-state info contains information of the async operations it has started but not necessarily finished.- Parameters:
name
- specifies the instance name of the state machine.state
- specifies the current state of the state machine.driveBase
- specifies the robot drive base, can be null if the state does not involve robot movement.ppDrive
- specifies the purePursuitDrive object, can be null if the state does not involve pp drive.
-
tracePostStateInfo
This method logs a post-state info event using the global tracer. The post-state info event can be used to debug a state machine after the state was executed. If the state involves PID controlled driving, it also logs the robot's movement. Post-state info contains information of the async operations it has started but not necessarily finished.- Parameters:
name
- specifies the instance name of the state machine.state
- specifies the current state of the state machine.battery
- specifies the robot battery object, can be null if not interested in battery info.
-