RWTraceLevelFilter RWTraceSingleClientfilter RWTraceEventFilter... ... RWTraceEventClient
#include <rw/trace/RWTraceLevelFilter.h>
RWTraceLevelFilter is a single-client filter that lets only events of the supplied severity level or higher pass through.
#define RW_USER_TRACE_LEVEL 8 //1 #include <rw/trace/trace.h> int main() { RWTraceOstreamClient myTraceClient(cerr); //2 // create filter that only lets INFO and more important events // pass through RWTraceLevelFilter myTraceLevelFilter(RW_TRACE_LEVEL_INFO);//3 // connect client to level filter myTraceClient.connect(myTraceLevelFilter); //4 // connect level filter to manager myTraceLevelFilter.connectToManager(); //5 RW_USER_TRACEABLE_FUNCTION("main"); //6 // generate some trace information RW_USER_TRACE_INFO("This info level message should be seen."); // change the level myTraceLevelFilter.setLevel(RW_TRACE_LEVEL_ERROR); //7 // generate some more trace information RW_USER_TRACE_INFO("This info level message should not be seen."); RW_USER_TRACE_ERROR("This error level message should be seen."); return 0; }
The following is a description of each program line:
//1 | Compile in all trace macros by setting the user trace level macro to 8. This line sets the maximum trace level to compile into the code. To compile in all the trace macros, the level is set to the maximum 8 (Entry/Exit). You could also define the trace level on the command line for your compiler, using the flag -DRW_USER_TRACE_LEVEL=8. |
//2 | Create a normal ostream client to display the trace information. |
//3 | Instantiate an RWTraceLevelFilter. The constructor takes the maximum level of trace messages to pass through. You can pass an integer level number (see Section 6.1.3 of the Threads.h++ User's Guide) or use one of the symbolic constants, as in this line. Pass 0 to filter out all trace messages. |
//4 | Connect the client to the level filter. |
//5 | Then connect the filter to the trace manager. |
//6 | Declare the function as traceable, so you can use trace event generation macros in this function. |
//7 | Change the cutoff level on the level filter, using the setLevel() function. |
The symbolic constants referred to in line //3 are defined in the file
rw/trace/RWTraceEventSeverity.h. They cannot be used when setting the RW_USER_TRACE_LEVEL macro, because this macro needs to be set before including any trace header files. They include:
RW_TRACE_LEVEL_FATAL
RW_TRACE_LEVEL_ERROR
RW_TRACE_LEVEL_WARNING
RW_TRACE_LEVEL_INFO
RW_TRACE_LEVEL_TEST
RW_TRACE_LEVEL_DEBUG
RW_TRACE_LEVEL_ENTRY
RW_TRACE_LEVEL_NONE
All of these constants map directly to the appropriate severity level. RW_TRACE_LEVEL_NONE filters out all trace messages. It is equivalent to zero.
RWTraceLevelFilter(RWStaticCtor);
Constructs a global static handle instance (may be used before being constructed).
RWTraceLevelFilter(RWTraceEventSeverity level = RW_TRACE_LEVEL_NONE);
Default constructor. If no level is supplied, the default is RW_TRACE_LEVEL_NONE. In this case, no events are passed on.
RWTraceLevelFilter(RWTraceLevelFilterImp* bodyP);
Attaches to and increments the reference count on a body.
RWTraceLevelFilter(const RWTraceLevelFilter& second);
Copy constructor.
RWTraceEventSeverity getLevel() const;
Returns the filter's severity level.
void setLevel(const RWTraceEventSeverity level);
Sets the severity level for the filter.
©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.