Class TrcDbgTrace

java.lang.Object
trclib.robotcore.TrcDbgTrace

public class TrcDbgTrace extends Object
This class implements the Debug Tracer.
  • Field Details

  • Constructor Details

    • TrcDbgTrace

      public TrcDbgTrace(String callerName, TrcDbgTrace.DbgLog dbgLog)
      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

      public void setTraceLevel(TrcDbgTrace.MsgLevel msgLevel)
      This method sets the message level for this tracer.
      Parameters:
      msgLevel - specifies the message level.
    • getTraceLevel

      public TrcDbgTrace.MsgLevel getTraceLevel()
      This method returns the trace message level.
      Returns:
      trace message level.
    • getGlobalTracer

      public static TrcDbgTrace 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

      public static boolean openTraceLog(String traceLogName)
      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

      public static boolean openTraceLog(String folderPath, String fileName)
      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

      public static String 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

      public static void printExceptionStack(Exception e)
      This method prints the exception stack to the global tracer.
      Parameters:
      e - specifies the exception.
    • printThreadStack

      public static void printThreadStack(Thread thread)
      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

      public boolean isMsgLevelEnabled(TrcDbgTrace.MsgLevel level)
      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

      public void traceFatal(String callerInstance, String text)
      This method is called to print a fatal message.
      Parameters:
      callerInstance - specifies the name to identify the caller.
      text - specifies the message text.
    • traceFatal

      public void traceFatal(String callerInstance, String format, Object... args)
      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

      public void traceErr(String callerInstance, String text)
      This method is called to print an error message.
      Parameters:
      callerInstance - specifies the name to identify the caller.
      text - specifies the message text.
    • traceErr

      public void traceErr(String callerInstance, String format, Object... args)
      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

      public void traceWarn(String callerInstance, String text)
      This method is called to print a warning message.
      Parameters:
      callerInstance - specifies the name to identify the caller.
      text - specifies the message text.
    • traceWarn

      public void traceWarn(String callerInstance, String format, Object... args)
      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

      public void traceInfo(String callerInstance, String text)
      This method is called to print an information message.
      Parameters:
      callerInstance - specifies the name to identify the caller.
      text - specifies the message text.
    • traceInfo

      public void traceInfo(String callerInstance, String format, Object... args)
      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

      public void traceDebug(String callerInstance, String text)
      This method is called to print a debug message.
      Parameters:
      callerInstance - specifies the name to identify the caller.
      text - specifies the message text.
    • traceDebug

      public void traceDebug(String callerInstance, String format, Object... args)
      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

      public void traceVerbose(String callerInstance, String text)
      This method is called to print a verbose message.
      Parameters:
      callerInstance - specifies the name to identify the caller.
      text - specifies the message text.
    • traceVerbose

      public void traceVerbose(String callerInstance, String format, Object... args)
      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

      public static void globalTraceFatal(String callerInstance, String text)
      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

      public static void globalTraceFatal(String callerInstance, String format, Object... args)
      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

      public static void globalTraceErr(String callerInstance, String text)
      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

      public static void globalTraceErr(String callerInstance, String format, Object... args)
      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

      public static void globalTraceWarn(String callerInstance, String text)
      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

      public static void globalTraceWarn(String callerInstance, String format, Object... args)
      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

      public static void globalTraceInfo(String callerInstance, String text)
      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

      public static void globalTraceInfo(String callerInstance, String format, Object... args)
      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

      public static void globalTraceDebug(String callerInstance, String text)
      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

      public static void globalTraceDebug(String callerInstance, String format, Object... args)
      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

      public static void globalTraceVerbose(String callerInstance, String text)
      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

      public static void globalTraceVerbose(String callerInstance, String format, Object... args)
      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

      public void logInfo(String callerInstance, String infoName, String text)
      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

      public void logInfo(String callerInstance, String infoName, String format, Object... args)
      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

      public void logEvent(String callerInstance, 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.
      eventName - specifies the name to identify the event.
      text - specifies the message text.
    • logEvent

      public void logEvent(String callerInstance, String eventName, String format, Object... args)
      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

      public void tracePreStateInfo(String name, Object state)
      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

      public void tracePostStateInfo(String name, Object state, 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.
      battery - specifies the robot battery object, can be null if not interested in battery info.