Class Trace


  • public final class Trace
    extends Object
    This auto registering class is used to define trace areas and issue messages. The implementer defines an instances of the jfTrace class in the file scope to ensure all trace areas are available before run-time. These instances then are registered with the jfTraceHandler during its construction
      
      example:
     
                    Trace oDataTrace = new Trace("data", ResId.DataTraceHelp);
                    Trace oStringTrace new Trace("string" ResId.StringTraceHelp);
                    main(...)
                    {
                            TraceHandler oTraceHandler = new TraceHandler();
     
                            TraceHandler.registerTraceHandler(oTraceHandler);
     
                            // two ways to activate 
                            oTraceHandler.activate("data", 2);
                            oStringTrace.activate(3);
     
                            ...
                            oTraceHandler.trace(oDataTrace, 2, 27, "data msg"); // issue message
                            ...
                            oDataTrace.trace(2, 33, "string msg"); // issue message
                            ...
                    }
     
      
     
    • Constructor Detail

      • Trace

        public Trace​(String sName,
                     int nHelpId)
        Constructor Registers the trace with a global storage area.
        Parameters:
        sName - the name of the trace section for which the message will be issued
        nHelpId - the message Id associated with a one-line help message for this trace section.
    • Method Detail

      • isEnabled

        public static boolean isEnabled​(String sName,
                                        int nLevel)
        Check if this trace section is enabled on the current thread
        Parameters:
        sName - - the name of the trace section for which the message will be issued
        nLevel - - the detail level of the messages allowed,
        Returns:
        true if this trace section is enabled on the current thread, else false
      • trace

        public static void trace​(String sName,
                                 int nLevel,
                                 int nId,
                                 String sMsg)
        Issues a trace message on the current thread.
        Parameters:
        sName - the name of the trace section for which the message will be issued
        nLevel - the detail level of the message, 1 for high level information, 3 for detailed information.
        nId - the message Id.
        sMsg - the message text.
      • trace

        public static void trace​(String sName,
                                 int nLevel,
                                 MsgFormatPos oMsg)
        Issues a trace message.
        Parameters:
        sName - the name of the trace section for which the message will be issued
        nLevel - the detail level of the message, 1 for high level information, 3 for detailed information.
        oMsg - the message for the trace.
      • activate

        public void activate​(int nLevel)
        Activates this trace section for the current thread
        Parameters:
        nLevel - the detail level of the messages allowed, 1 for high level information, 3 for detailed information.
      • deactivate

        public void deactivate()
        Deactivates this trace section for the current thread
      • getHelpId

        public int getHelpId()
      • getName

        public String getName()
        Returns the name of this trace section
        Returns:
        the name of this trace section
      • isEnabled

        public boolean isEnabled​(int nLevel)
        Check if this trace section is enabled on the current thread.
        Parameters:
        nLevel - the detail level of the messages allowed,
        Returns:
        true if this trace section is enabled on the current thread, else false
      • trace

        public void trace​(int nLevel,
                          int nId,
                          String sMsg)
        Issues a trace message.
        Parameters:
        nLevel - the detail level of the message, 1 for high level information, 3 for detailed information.
        nId - the message Id.
        sMsg - the message text.
      • trace

        public void trace​(int nLevel,
                          MsgFormatPos oMsg)
        Issues a trace message.
        Parameters:
        nLevel - the detail level of the message, 1 for high level information, 3 for detailed information.
        oMsg - the message for the trace.