Class TraceHandler


  • public final class TraceHandler
    extends java.lang.Object
    This trace handler class manages Trace areas for a given thread and outputs trace messages to standard out. If an application uses tracing it should create one instance of this class for each thread.
     
     example:
    
                    Trace dataTrace = new Trace("data", ResId.DataTraceHelp);
                    Trace stringTrace = new Trace("string" ResId.StringTraceHelp);
                    main(...)
                    {
                            TraceHandler traceHandler = new TraceHandler();
    
                            TraceHandler.registerTraceHandler(traceHandler);
    
                            // three ways to activate 
                            traceHandler.activate("data", 2);
                            traceHandler.activate("data:2 eval:3 signature:1");
                            stringTrace.activate(3);
    
                            ...
                            traceHandler.trace(dataTrace, 2, 27, "data msg"); // issue message
                            ...
                            dataTrace.trace(2, 33, "string msg"); // issue message
                            ...
                    }
    
     
    • Constructor Detail

      • TraceHandler

        public TraceHandler​(int nThreadId)
        Constructor
        Parameters:
        nThreadId - the thread id of the current thread
    • Method Detail

      • timingTraceEnabled

        public static void timingTraceEnabled​(boolean bEnabled)
      • timingTraceEnabled

        public static boolean timingTraceEnabled()
      • scriptLoggingEnabled

        public static boolean scriptLoggingEnabled()
      • resetTiming

        public static void resetTiming()
      • initializeTiming

        public static void initializeTiming()
      • reportScriptInfo

        public static void reportScriptInfo​(java.lang.String sMsg)
      • reportTimingResults

        public static void reportTimingResults​(boolean bClearStoppedTimers)
      • getTraceHandler

        public static TraceHandler getTraceHandler()
        Get the TraceHandler for the current thread.
        Returns:
        the TraceHandler assigned to the current thread.
      • registerTraceHandler

        public static void registerTraceHandler​(TraceHandler traceHandler)
        Registers the trace handler for the current thread.
      • unregisterTraceHandler

        public static void unregisterTraceHandler()
        Unregisters a trace handler for the current thread.
      • activate

        public void activate​(Trace trace,
                             int nLevel)
        Activates a trace section
        Parameters:
        trace - a globally defined Trace object
        nLevel - the detail level of the messages allowed, higher the level greater the detail
      • activate

        public void activate​(java.lang.String sName,
                             int nLevel)
        Activates a trace section
        Parameters:
        sName - the name of a globally defined Trace object
        nLevel - the detail level of the messages allowed higher the level greater the detail
      • activate

        public void activate​(java.lang.String sNamesAndLevels)
        Activates one or more trace sections
        Parameters:
        sNamesAndLevels - the whitespace-separated list of trace names and the associated detail level. For example: "eval:2 signature:1". This is the same format as a command line argument, so the argument following the -trace argument (by convention) can be passed to this method.
      • deactivate

        public void deactivate​(java.lang.String sName)
        Deactivates a trace section
        Parameters:
        sName - the name of a globally defined Trace object
      • getThreadId

        public int getThreadId()
        Get the thread ID of this TraceHandler
        Returns:
        thread ID