SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
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 (const RWTraceLevelFilter &second)
 
 RWTraceLevelFilter (RWStaticCtor)
 
 RWTraceLevelFilter (RWTraceEventSeverity level)
 
 RWTraceLevelFilter (RWTraceLevelFilterImp *bodyP)
 
 ~RWTraceLevelFilter (void)
 
RWTraceEventSeverity getLevel () const
 
void setLevel (RWTraceEventSeverity level)
 
- Public Member Functions inherited from RWTraceSingleClientFilter
 RWTraceSingleClientFilter (const RWTraceSingleClientFilter &second)
 
 RWTraceSingleClientFilter (RWStaticCtor)
 
 RWTraceSingleClientFilter (RWTraceSingleClientFilterImp *bodyP)
 
 RWTraceSingleClientFilter (void)
 
 ~RWTraceSingleClientFilter (void)
 
void disconnectClient (void)
 
RWTraceSingleClientFilteroperator= (const RWTraceSingleClientFilter &second)
 
- Public Member Functions inherited from RWTraceEventFilter
 RWTraceEventFilter ()
 
 RWTraceEventFilter (const RWTraceEventFilter &second)
 
 RWTraceEventFilter (RWStaticCtor)
 
 RWTraceEventFilter (RWTraceEventFilterImp *bodyP)
 
 ~RWTraceEventFilter (void)
 
RWTraceEventFilteroperator= (const RWTraceEventFilter &second)
 
- Public Member Functions inherited from RWTraceEventClient
 RWTraceEventClient ()
 
 RWTraceEventClient (const RWTraceEventClient &second)
 
 RWTraceEventClient (RWStaticCtor)
 
 RWTraceEventClient (RWTraceEventClientImp *bodyP)
 
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;
}
A handle class for a single-client filter that lets events only of the supplied severity level or hig...
Definition RWTraceLevelFilter.h:121
A handle class for a trace event client that sends all events to an std::ostream.
Definition RWTraceOstreamClient.h:49
#define RW_USER_TRACE_TEST(msg)
Definition userdefs.h:315
#define RW_USER_TRACE_WARNING(msg)
Definition userdefs.h:283
#define RW_USER_TRACE_ERROR(msg)
Definition userdefs.h:267
#define RW_USER_TRACE_DEBUG(msg)
Definition userdefs.h:331
#define RW_USER_TRACEABLE_FUNCTION(functionTag)
Definition userdefs.h:158
#define RW_USER_TRACE_FATAL(msg)
Definition userdefs.h:251
#define RW_USER_TRACE_INFO(msg)
Definition userdefs.h:299
@ RW_TRACE_LEVEL_ERROR
Definition RWTraceEventSeverity.h:50
@ RW_TRACE_LEVEL_INFO
Definition RWTraceEventSeverity.h:60

//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() [1/5]

RWTraceLevelFilter::RWTraceLevelFilter ( )

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

◆ RWTraceLevelFilter() [2/5]

RWTraceLevelFilter::RWTraceLevelFilter ( RWTraceEventSeverity level)

Constructs an instance with a severity filter level level.

◆ RWTraceLevelFilter() [3/5]

RWTraceLevelFilter::RWTraceLevelFilter ( RWTraceLevelFilterImp * bodyP)

Attaches to and increments the reference count on bodyP.

◆ RWTraceLevelFilter() [4/5]

RWTraceLevelFilter::RWTraceLevelFilter ( RWStaticCtor )

Constructs a global static handle instance (that may be used before being constructed).

◆ RWTraceLevelFilter() [5/5]

RWTraceLevelFilter::RWTraceLevelFilter ( const RWTraceLevelFilter & second)

Attaches to and increments the reference count on the body of second.

◆ ~RWTraceLevelFilter()

RWTraceLevelFilter::~RWTraceLevelFilter ( void )

Destructor.

Member Function Documentation

◆ getLevel()

RWTraceEventSeverity RWTraceLevelFilter::getLevel ( ) const

Returns the filter's severity level.

◆ setLevel()

void RWTraceLevelFilter::setLevel ( RWTraceEventSeverity level)

Sets the severity level for the filter.

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