Rogue Wave banner
Previous fileTop of DocumentContentsIndexNext file

6.3 Using Trace

These are the basic steps required to generate trace output:

  1. Put set declaration macros in your code to make the functions traceable. (See Section 6.4, "Using Set Declaration Macros.")

  2. Put trace event macros in your code to generate trace output. (See Section 6.5, "Using Event Generation Macros.")

  3. Create at least one trace event client to process the trace output. (See Section 6.7, "Using Trace Clients.")

  4. Choose a combination of compile time and runtime options for controlling the severity levels of the events reported. (See Section 6.10, "Controlling Trace Output.")

  5. Define environment variables to turn sets on or off at runtime. (See Section 6.4.4, "Setting Environment Variables for Event Sets.")

Example 52 illustrates the steps required to generate trace output in a global function. The following code is taken from examples\thr0200osfam\trace\helloTrace.cpp.

Example 52 -- Generating trace output

A description of each program line follows:

//1Set the trace level to maximum (8). This ensures that all trace events are compiled into the executable. If you define the trace level in the program, as shown here, this macro must be set before including trace.h. This macro could also be set on the command line when the program is compiled, using the -DRW_USER_TRACE_LEVEL=8 flag.
//2Include the trace umbrella header.
//3Create a client that logs messages to cerr. The function is declared global, so that all events from main() are processed before the client's destruction.
//4This is a set declaration macro. It declares the function as traceable and assigns it the name main, which is used as the environment variable name to toggle the generation of trace events in this function. This macro also generates the function ENTRY and EXIT events.
//5Connect the client to the trace manager.
//6This is an event generation macro. It generates a DEBUG trace event.
//7This is also an event generation macro. It generates an INFO trace event.

To see output, set the main or rw_user environment variable to ON. rw_user works because the main() function is declared on line //3 to be a member of the predefined rw_user package set. The program produces this output:


Previous fileTop of DocumentContentsIndexNext file

©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.