Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Threads Module User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

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 buildspace\examples\trace\helloTrace.cpp.

Example 52: Generating trace output

//1

Set 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.

//2

Include the trace umbrella header.

//3

Create 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.

//4

This 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.

//5

Connect the client to the trace manager.

//6

This is an event generation macro. It generates a DEBUG trace event.

//7

This 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 DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and SourcePro, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.