SourcePro® API Reference Guide

Product Documentation:
   SourcePro
Documentation Home
List of all members | Public Member Functions
RWTraceLevelFilter Class Reference

A handle class for a single-client filter that lets events only of the supplied severity level or higher to pass through. More...

#include <rw/trace/RWTraceLevelFilter.h>

Inheritance diagram for RWTraceLevelFilter:
RWTraceSingleClientFilter RWTraceEventFilter RWTraceEventClient RWTraceManager

Public Member Functions

 RWTraceLevelFilter ()
 
 RWTraceLevelFilter (RWTraceEventSeverity level)
 
 RWTraceLevelFilter (RWTraceLevelFilterImp *bodyP)
 
 RWTraceLevelFilter (RWStaticCtor)
 
 RWTraceLevelFilter (const RWTraceLevelFilter &second)
 
 ~RWTraceLevelFilter (void)
 
RWTraceEventSeverity getLevel () const
 
void setLevel (RWTraceEventSeverity level)
 
- Public Member Functions inherited from RWTraceSingleClientFilter
 RWTraceSingleClientFilter (void)
 
 RWTraceSingleClientFilter (RWTraceSingleClientFilterImp *bodyP)
 
 RWTraceSingleClientFilter (RWStaticCtor)
 
 RWTraceSingleClientFilter (const RWTraceSingleClientFilter &second)
 
 ~RWTraceSingleClientFilter (void)
 
void disconnectClient (void)
 
RWTraceSingleClientFilteroperator= (const RWTraceSingleClientFilter &second)
 
- Public Member Functions inherited from RWTraceEventFilter
 RWTraceEventFilter ()
 
 RWTraceEventFilter (RWTraceEventFilterImp *bodyP)
 
 RWTraceEventFilter (RWStaticCtor)
 
 RWTraceEventFilter (const RWTraceEventFilter &second)
 
 ~RWTraceEventFilter (void)
 
RWTraceEventFilteroperator= (const RWTraceEventFilter &second)
 
- Public Member Functions inherited from RWTraceEventClient
 RWTraceEventClient ()
 
 RWTraceEventClient (RWTraceEventClientImp *bodyP)
 
 RWTraceEventClient (RWStaticCtor)
 
 RWTraceEventClient (const RWTraceEventClient &second)
 
virtual ~RWTraceEventClient (void)
 
void connect (RWTraceEventFilter &filter)
 
void connectToManager (void)
 
void disconnect (void)
 
bool isValid (void) const
 
bool operator!= (const RWTraceEventClient &second) const
 
RWTraceEventClientoperator= (const RWTraceEventClient &second)
 
RWTraceEventClientoperator= (RWTraceEventClientImp *ptr)
 
bool operator== (const RWTraceEventClient &second) const
 
void orphan (void)
 
void trace (const RWTraceEvent &ev)
 
void validate (void) const
 

Additional Inherited Members

- Protected Member Functions inherited from RWTraceEventClient
RWTraceEventClientImpgetBody (void) const
 
void transfer (RWTraceEventClientImp *bodyP=0)
 

Detailed Description

RWTraceLevelFilter is a single-client trace filter that accepts events only of the supplied severity level or higher, and forwards them to a client.

Example

This example is located in your installation directory at examples/trace/LevelFilter.cpp.

#define RW_USER_TRACE_LEVEL 8 //1
#include <rw/trace/trace.h>
int main(void)
{
// declare function as traceable with the set name "main"
// this also generates an entry/exit event
// create trace client that logs messages to cerr
RWTraceOstreamClient client(std::cerr); //3
// create filter that lets only INFO and more important
// events pass through
// connect client to level filter
client.connect(levelFilter); //5
// connect level filter to manager
levelFilter.connectToManager(); //6
// generate some trace information; these trace events
// will belong to the sets "rw_user" and "main"
RW_USER_TRACE_DEBUG("Debug (hidden)");
RW_USER_TRACE_TEST("Test (hidden)");
// change the level
levelFilter.setLevel(RW_TRACE_LEVEL_ERROR); //7
// generate some more trace information; these trace
// events will belong to the sets "rw_user" and "main"
RW_USER_TRACE_DEBUG("Debug (hidden)");
RW_USER_TRACE_TEST("Test (hidden)");
RW_USER_TRACE_INFO("Info (hidden)");
RW_USER_TRACE_WARNING("Warning (hidden)");
return 0;
}

//1 Compile in all trace macros by setting the user trace level macro to 8, the maximum (Entry/Exit) level. You can also define the trace level on the command line for your compiler, using the flag -DRW_USER_TRACE_LEVEL=8.

//2 Declare the function as traceable, so you can use trace event generation macros in this function.

//3 Create a normal std::ostream client to display the trace information.

//4 Instantiate an RWTraceLevelFilter. The constructor takes the minimum severity (i.e. the maximum level) of trace messages to pass through. You can pass an integer level number cast to RWTraceEventSeverity or use one of the symbolic constants, as in this line. Pass RW_TRACE_LEVEL_NONE to filter out all trace messages. See the discussion on trace level filters in the Threads Module User's Guide for a definition of the severity levels.

//5 Connect the client to the level filter.

//6 Then connect the filter to the trace manager.

//7 Change the cutoff level on the level filter, using the setLevel() function.

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.

Constructor & Destructor Documentation

RWTraceLevelFilter::RWTraceLevelFilter ( )

Default constructor. The default level is RW_TRACE_LEVEL_NONE; no events are passed on.

RWTraceLevelFilter::RWTraceLevelFilter ( RWTraceEventSeverity  level)

Constructs an instance with a severity filter level level.

RWTraceLevelFilter::RWTraceLevelFilter ( RWTraceLevelFilterImp bodyP)

Attaches to and increments the reference count on bodyP.

RWTraceLevelFilter::RWTraceLevelFilter ( RWStaticCtor  )

Constructs a global static handle instance (that 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.

Member Function Documentation

RWTraceEventSeverity RWTraceLevelFilter::getLevel ( ) const

Returns the filter's severity level.

void RWTraceLevelFilter::setLevel ( RWTraceEventSeverity  level)

Sets the severity level for the filter.

Copyright © 2021 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.