class trace

The trace class allows you to easily produce tracing diagnostics. More...

Full namedbg::trace
Definition#include <dbg.h>
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods


Detailed Description

The trace class allows you to easily produce tracing diagnostics.

When the ctor is called, it prints "->" and the name of the function, increasing the indent level. When the object is deleted it prints "<-" followed again by the name of the function.

You can use the name of the current function gathered via the DBG_HERE macro, or some other tracing string you supply.

Diagnostics are produced at the tracing level.

For example, if you write the following code:


     void foo()
     {
         dbg::trace t1(DBG_HERE);
         // do some stuff
         {
             dbg::trace t2("sub block");
             // do some stuff
             dbg::out(tracing) << dbg::prefix() << "Hello!\n";
         }
         dbg::out(tracing) << dbg::prefix() << "Hello again!\n";
         // more stuff
     }

You will get the following tracing information:


     *** ->foo (0 in foo.cpp)
     ***   ->sub block
     ***     Hello!
     ***   <-sub block
     ***   Hello again!
     *** <-foo (0 in foo.cpp)

Don't forget to create named dbg::trace objects. If you create anonymous objects (i.e. you just wrote "dbg::trace(DBG_HERE);") then the destructor will be called immediately, rather than at the end of the block scope, causing invalid trace output.

Tracing does not cause assertions to trigger, therefore you will never generate an abort or exception using this object.

If you disable the tracing diagnostic level before the trace object's destructor is called you will still get the closing trace output. This is important, otherwise the indentation level of the library would get out of sync. In this case, the closing diagnostic output will have a "note" attached to indicate what has happened.

Similarly, if tracing diagnostics are off when the trace object is created, yet subsequently enabled before the destructor there will be no closing tracing output.

 trace (func_name_t name)

trace

Provide the function name, or some other tracing string.

This will not tie the trace object to a particular dbg_source.

Parameters:
nameTracing block name

 trace (dbg_source src, func_name_t name)

trace

Parameters:
srcString describing the diagnostic source
nameTracing block name

 trace (const source_pos &here)

trace

This will not tie the trace object to a particular dbg_source.

Parameters:
hereSupply DBG_HERE

 trace (dbg_source src, const source_pos &here)

trace

Parameters:
srcString describing the diagnostic source
hereSupply DBG_HERE

 ~trace ()

~trace

 trace (const char *fn_name)

trace

 trace (dbg_source, const char *fn_name)

trace

 trace (void *here)

trace

 trace (dbg_source, void *here)

trace

 ~trace ()

~trace


Generated by: pg1 on imgpc030 on Tue Sep 16 13:46:16 2003, using kdoc 2.0a54.