SourcePro 11.1 |
SourcePro® C++ API Reference Guide |
SourcePro C++ Documentation Home |
A handle class for a single-client filter that lets only events of the supplied severity level or higher pass through. More...
#include <rw/trace/RWTraceLevelFilter.h>
Public Member Functions | |
RWTraceLevelFilter (RWTraceEventSeverity level=RW_TRACE_LEVEL_NONE) | |
RWTraceLevelFilter (RWTraceLevelFilterImp *bodyP) | |
RWTraceLevelFilter (RWStaticCtor) | |
RWTraceLevelFilter (const RWTraceLevelFilter &second) | |
~RWTraceLevelFilter (void) | |
RWTraceEventSeverity | getLevel () const |
void | setLevel (RWTraceEventSeverity level) |
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 std::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 Module 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:
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::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::RWTraceLevelFilter | ( | RWTraceLevelFilterImp * | bodyP | ) |
Attaches to and increments the reference count on bodyP .
RWTraceLevelFilter::RWTraceLevelFilter | ( | RWStaticCtor | ) |
Constructs a global static handle instance (may be used before being constructed).
RWTraceLevelFilter::RWTraceLevelFilter | ( | const RWTraceLevelFilter & | second | ) |
Attaches to and increments the reference count on the body of second .
RWTraceLevelFilter::~RWTraceLevelFilter | ( | void | ) |
Destructor.
RWTraceEventSeverity RWTraceLevelFilter::getLevel | ( | ) | const |
Returns the filter's severity level.
void RWTraceLevelFilter::setLevel | ( | RWTraceEventSeverity | level | ) |
Sets the severity level for the filter.
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.