SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches

Provides a runtime trace facility for DB Interface Module applications. More...

#include <rw/db/tracer.h>

Public Types

enum  TraceFlag { SQL , BoundBuffers , NoPlaceHolderSQL , ThreadID }
 

Public Member Functions

 RWDBTracer ()
 
 RWDBTracer (const RWDBTracer &aTrace)
 
void acquire () const
 
unsigned flag () const
 
bool isOn (TraceFlag flag) const
 
bool isValid ()
 
RWDBTraceroperator<< (char arg)
 
RWDBTraceroperator<< (const char *str)
 
RWDBTraceroperator<< (const signed char *arg)
 
RWDBTraceroperator<< (const unsigned char *arg)
 
RWDBTraceroperator<< (double arg)
 
RWDBTraceroperator<< (float arg)
 
RWDBTraceroperator<< (int arg)
 
RWDBTraceroperator<< (long arg)
 
RWDBTraceroperator<< (long double arg)
 
RWDBTraceroperator<< (long long arg)
 
RWDBTraceroperator<< (short arg)
 
RWDBTraceroperator<< (signed char arg)
 
RWDBTraceroperator<< (std::ios &(*f)(std::ios &))
 
RWDBTraceroperator<< (std::ostream &(*f)(std::ostream &))
 
RWDBTraceroperator<< (unsigned char arg)
 
RWDBTraceroperator<< (unsigned int arg)
 
RWDBTraceroperator<< (unsigned long arg)
 
RWDBTraceroperator<< (unsigned long long arg)
 
RWDBTraceroperator<< (unsigned short arg)
 
RWDBTraceroperator<< (void *arg)
 
RWDBTraceroperator= (const RWDBTracer &aTrace)
 
void release () const
 
unsigned setOff (TraceFlag flags)
 
unsigned setOn (TraceFlag flags)
 
std::ostream & stream ()
 
RWDBTracerstream (std::ostream &strm)
 

Detailed Description

Class RWDBTracer provides a runtime trace facility for DB Interface Module applications. RWDBTracer objects can be turned ON or OFF, and they can be told what to trace. The default output for an RWDBTracer is the std::ostream std::clog. The output from an RWDBTracer can be redirected to an std::ostream.

A database object of the DB Interface Module contains an RWDBTracer. Consequently, enabling tracing on an RWDBDatabase, for example, produces trace output for all objects produced by that RWDBDatabase.

It is the application's responsibility to ensure that the associated std::ostream referenced by the RWDBTracer remains in scope while the RWDBTracer is set ON.

Synopsis
#include <rw/db/tracer.h>
#include <fstream>
std::ofstream strm("trace.trc");
RWDBTracer& tracer = myDbase.tracer();
tracer.stream(strm);
Provides a runtime trace facility for DB Interface Module applications.
Definition tracer.h:67
RWDBTracer & stream(std::ostream &strm)
unsigned setOn(TraceFlag flags)
@ SQL
Definition tracer.h:80
See also
RWDBDatabase instances provide access to its RWDBTracer.
Example
RWDBTracer& tracer = myDbase.tracer();
std::ofstream strm("trace.out");
tracer.stream(strm);

Member Enumeration Documentation

◆ TraceFlag

Defines the values that tell an RWDBTracer what to trace.

Enumerator
SQL 

Traces all SQL sent to the database through the traced object

BoundBuffers 

Traces all the data sent to the database in input-bound buffers

NoPlaceHolderSQL 

Traces all SQL sent to the database through the traced object, and replaces any placeholders in the SQL with their contents. When placeholders are bound as arrays, the SQL is repeated for each value in the arrays

ThreadID 

If turned ON in multithreaded builds, prints the thread id of the execution thread in the tracer stream. The thread id is printed for all three types of tracer output. For single-threaded builds, this setting does nothing. By default, ThreadID is OFF

Constructor & Destructor Documentation

◆ RWDBTracer() [1/2]

RWDBTracer::RWDBTracer ( )

Default constructor that produces an RWDBTracer not associated with any object. To obtain useful trace information, get an RWDBTracer reference from an RWDBDatabase.

◆ RWDBTracer() [2/2]

RWDBTracer::RWDBTracer ( const RWDBTracer & aTrace)

Copy constructor. RWDBTracer objects are copied by value.

Member Function Documentation

◆ acquire()

void RWDBTracer::acquire ( ) const

Attempts to acquire the internal mutex lock. If the mutex is already locked by another thread, the function blocks until the mutex is released. This function can be called from a const object.

Note
In single-threaded builds, this function evaluates to a no-op.

◆ flag()

unsigned RWDBTracer::flag ( ) const

Returns a bit-mask representing the categories of tracing currently enabled.

◆ isOn()

bool RWDBTracer::isOn ( TraceFlag flag) const

Returns true if the trace category represented by flag is currently enabled, otherwise returns false.

◆ isValid()

bool RWDBTracer::isValid ( )

Returns false if the attached std::ostream encounters an EOF or if the bad bit has been set, otherwise true.

◆ operator<<() [1/20]

RWDBTracer & RWDBTracer::operator<< ( char arg)

Values may be streamed out through an RWDBTracer, much as through a std::ostream, allowing applications to annotate the trace output. Structured objects may be streamed out by defining a function of the form:

RWDBTracer& operator<<(RWDBTracer& tracer, someStruct& s);
RWDBTracer & operator<<(char arg)

◆ operator<<() [2/20]

RWDBTracer & RWDBTracer::operator<< ( const char * str)

Values may be streamed out through an RWDBTracer, much as through a std::ostream, allowing applications to annotate the trace output. Structured objects may be streamed out by defining a function of the form:

RWDBTracer& operator<<(RWDBTracer& tracer, someStruct& s);

◆ operator<<() [3/20]

RWDBTracer & RWDBTracer::operator<< ( const signed char * arg)

Values may be streamed out through an RWDBTracer, much as through a std::ostream, allowing applications to annotate the trace output. Structured objects may be streamed out by defining a function of the form:

RWDBTracer& operator<<(RWDBTracer& tracer, someStruct& s);

◆ operator<<() [4/20]

RWDBTracer & RWDBTracer::operator<< ( const unsigned char * arg)

Values may be streamed out through an RWDBTracer, much as through a std::ostream, allowing applications to annotate the trace output. Structured objects may be streamed out by defining a function of the form:

RWDBTracer& operator<<(RWDBTracer& tracer, someStruct& s);

◆ operator<<() [5/20]

RWDBTracer & RWDBTracer::operator<< ( double arg)

Values may be streamed out through an RWDBTracer, much as through a std::ostream, allowing applications to annotate the trace output. Structured objects may be streamed out by defining a function of the form:

RWDBTracer& operator<<(RWDBTracer& tracer, someStruct& s);

◆ operator<<() [6/20]

RWDBTracer & RWDBTracer::operator<< ( float arg)

Values may be streamed out through an RWDBTracer, much as through a std::ostream, allowing applications to annotate the trace output. Structured objects may be streamed out by defining a function of the form:

RWDBTracer& operator<<(RWDBTracer& tracer, someStruct& s);

◆ operator<<() [7/20]

RWDBTracer & RWDBTracer::operator<< ( int arg)

Values may be streamed out through an RWDBTracer, much as through a std::ostream, allowing applications to annotate the trace output. Structured objects may be streamed out by defining a function of the form:

RWDBTracer& operator<<(RWDBTracer& tracer, someStruct& s);

◆ operator<<() [8/20]

RWDBTracer & RWDBTracer::operator<< ( long arg)

Values may be streamed out through an RWDBTracer, much as through a std::ostream, allowing applications to annotate the trace output. Structured objects may be streamed out by defining a function of the form:

RWDBTracer& operator<<(RWDBTracer& tracer, someStruct& s);

◆ operator<<() [9/20]

RWDBTracer & RWDBTracer::operator<< ( long double arg)

Values may be streamed out through an RWDBTracer, much as through a std::ostream, allowing applications to annotate the trace output. Structured objects may be streamed out by defining a function of the form:

RWDBTracer& operator<<(RWDBTracer& tracer, someStruct& s);

◆ operator<<() [10/20]

RWDBTracer & RWDBTracer::operator<< ( long long arg)

Values may be streamed out through an RWDBTracer, much as through a std::ostream, allowing applications to annotate the trace output. Structured objects may be streamed out by defining a function of the form:

RWDBTracer& operator<<(RWDBTracer& tracer, someStruct& s);

◆ operator<<() [11/20]

RWDBTracer & RWDBTracer::operator<< ( short arg)

Values may be streamed out through an RWDBTracer, much as through a std::ostream, allowing applications to annotate the trace output. Structured objects may be streamed out by defining a function of the form:

RWDBTracer& operator<<(RWDBTracer& tracer, someStruct& s);

◆ operator<<() [12/20]

RWDBTracer & RWDBTracer::operator<< ( signed char arg)

Values may be streamed out through an RWDBTracer, much as through a std::ostream, allowing applications to annotate the trace output. Structured objects may be streamed out by defining a function of the form:

RWDBTracer& operator<<(RWDBTracer& tracer, someStruct& s);

◆ operator<<() [13/20]

RWDBTracer & RWDBTracer::operator<< ( std::ios &(* )(std::ios &))

Values may be streamed out through an RWDBTracer, much as through a std::ostream, allowing applications to annotate the trace output. Structured objects may be streamed out by defining a function of the form:

RWDBTracer& operator<<(RWDBTracer& tracer, someStruct& s);

◆ operator<<() [14/20]

RWDBTracer & RWDBTracer::operator<< ( std::ostream &(* )(std::ostream &))

Values may be streamed out through an RWDBTracer, much as through a std::ostream, allowing applications to annotate the trace output. Structured objects may be streamed out by defining a function of the form:

RWDBTracer& operator<<(RWDBTracer& tracer, someStruct& s);

◆ operator<<() [15/20]

RWDBTracer & RWDBTracer::operator<< ( unsigned char arg)

Values may be streamed out through an RWDBTracer, much as through a std::ostream, allowing applications to annotate the trace output. Structured objects may be streamed out by defining a function of the form:

RWDBTracer& operator<<(RWDBTracer& tracer, someStruct& s);

◆ operator<<() [16/20]

RWDBTracer & RWDBTracer::operator<< ( unsigned int arg)

Values may be streamed out through an RWDBTracer, much as through a std::ostream, allowing applications to annotate the trace output. Structured objects may be streamed out by defining a function of the form:

RWDBTracer& operator<<(RWDBTracer& tracer, someStruct& s);

◆ operator<<() [17/20]

RWDBTracer & RWDBTracer::operator<< ( unsigned long arg)

Values may be streamed out through an RWDBTracer, much as through a std::ostream, allowing applications to annotate the trace output. Structured objects may be streamed out by defining a function of the form:

RWDBTracer& operator<<(RWDBTracer& tracer, someStruct& s);

◆ operator<<() [18/20]

RWDBTracer & RWDBTracer::operator<< ( unsigned long long arg)

Values may be streamed out through an RWDBTracer, much as through a std::ostream, allowing applications to annotate the trace output. Structured objects may be streamed out by defining a function of the form:

RWDBTracer& operator<<(RWDBTracer& tracer, someStruct& s);

◆ operator<<() [19/20]

RWDBTracer & RWDBTracer::operator<< ( unsigned short arg)

Values may be streamed out through an RWDBTracer, much as through a std::ostream, allowing applications to annotate the trace output. Structured objects may be streamed out by defining a function of the form:

RWDBTracer& operator<<(RWDBTracer& tracer, someStruct& s);

◆ operator<<() [20/20]

RWDBTracer & RWDBTracer::operator<< ( void * arg)

Values may be streamed out through an RWDBTracer, much as through a std::ostream, allowing applications to annotate the trace output. Structured objects may be streamed out by defining a function of the form:

RWDBTracer& operator<<(RWDBTracer& tracer, someStruct& s);

◆ operator=()

RWDBTracer & RWDBTracer::operator= ( const RWDBTracer & aTrace)

Assignment operator. RWDBTracer objects are copied by value.

◆ release()

void RWDBTracer::release ( ) const

Releases a previously acquired mutex. This function can be called from a const object.

Note
In single-threaded builds, this function evaluates to a no-op.

◆ setOff()

unsigned RWDBTracer::setOff ( TraceFlag flags)

Removes the categories represented by flags from those categories currently being traced by self. Returns the new bit-mask of traced categories.

◆ setOn()

unsigned RWDBTracer::setOn ( TraceFlag flags)

Adds the categories represented by flags to those categories currently being traced by self. Returns the new bit-mask of traced categories.

◆ stream() [1/2]

std::ostream & RWDBTracer::stream ( )

Returns a reference to the stream currently attached to self.

◆ stream() [2/2]

RWDBTracer & RWDBTracer::stream ( std::ostream & strm)

Directs all subsequent trace output to the supplied strm. The DB Interface Module does not check strm for validity. Returns a reference to self.

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