Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ACE_Trace Class Reference

A C++ trace facility that keeps track of which methods are entered and exited. More...

#include <Trace.h>

List of all members.

Public Methods

 ACE_Trace (const ACE_TCHAR *n, int line=0, const ACE_TCHAR *file=ACE_LIB_TEXT(""))
 Perform the first part of the trace, which prints out the string N, the LINE, and the ACE_FILE as the function is entered. More...

 ~ACE_Trace (void)
 Perform the second part of the trace, which prints out the NAME as the function is exited. More...

void dump (void) const
 Dump the state of an object. More...


Static Public Methods

int is_tracing (void)
 Determine if tracing is enabled (return == 1) or not (== 0). More...

void start_tracing (void)
 Enable the tracing facility. More...

void stop_tracing (void)
 Disable the tracing facility. More...

void set_nesting_indent (int indent)
 Change the nesting indentation level. More...

int get_nesting_indent (void)
 Get the nesting indentation level. More...


Private Types

enum  { DEFAULT_INDENT = 3, DEFAULT_TRACING = 1 }
 Default values. More...


Private Attributes

const ACE_TCHARname_
 Name of the method we are in. More...


Static Private Attributes

int nesting_indent_ = ACE_Trace::DEFAULT_INDENT
 Keeps track of how far to indent per trace call. More...

int enable_tracing_ = ACE_Trace::DEFAULT_TRACING
 Is tracing enabled? More...


Detailed Description

A C++ trace facility that keeps track of which methods are entered and exited.

This class uses C++ constructors and destructors to automate the ACE_Trace nesting. In addition, thread-specific storage is used to enable multiple threads to work correctly.

Definition at line 36 of file Trace.h.


Member Enumeration Documentation

anonymous enum [private]
 

Default values.

Enumeration values:
DEFAULT_INDENT 
DEFAULT_TRACING 

Definition at line 85 of file Trace.h.

00086   {
00087     DEFAULT_INDENT  = 3,
00088     DEFAULT_TRACING = 1
00089   };


Constructor & Destructor Documentation

ACE_Trace::ACE_Trace const ACE_TCHAR   n,
int    line = 0,
const ACE_TCHAR   file = ACE_LIB_TEXT("")
 

Perform the first part of the trace, which prints out the string N, the LINE, and the ACE_FILE as the function is entered.

Definition at line 78 of file Trace.cpp.

References ACE_DEBUG, ACE_LIB_TEXT, ACE_LOG_MSG, ACE_TCHAR, enable_tracing_, ACE_Log_Msg::inc, LM_TRACE, name_, nesting_indent_, ACE_OS_Object_Manager::starting_up, ACE_Log_Msg::trace_active, and ACE_Log_Msg::tracing_enabled.

00081 {
00082 #if defined (ACE_NLOGGING)
00083   ACE_UNUSED_ARG (line);
00084   ACE_UNUSED_ARG (file);
00085 #endif /* ACE_NLOGGING */
00086 
00087   this->name_ = n;
00088 
00089   // If ACE has not yet been initialized, don't try to trace... there's
00090   // too much stuff not yet initialized.
00091   if (ACE_Trace::enable_tracing_ && !ACE_OS_Object_Manager::starting_up ())
00092     {
00093       ACE_Log_Msg *lm = ACE_LOG_MSG;
00094       if (lm->tracing_enabled ()
00095           && lm->trace_active () == 0)
00096         {
00097           lm->trace_active (1);
00098           ACE_DEBUG ((LM_TRACE,
00099                       ACE_LIB_TEXT ("%*s(%t) calling %s in file `%s' on line %d\n"),
00100                       ACE_Trace::nesting_indent_ * lm->inc (),
00101                       ACE_LIB_TEXT (""),
00102                       this->name_,
00103                       file,
00104                       line));
00105           lm->trace_active (0);
00106         }
00107     }
00108 }

ACE_Trace::~ACE_Trace void   
 

Perform the second part of the trace, which prints out the NAME as the function is exited.

Definition at line 113 of file Trace.cpp.

References ACE_DEBUG, ACE_LIB_TEXT, ACE_LOG_MSG, ACE_Log_Msg::dec, enable_tracing_, LM_TRACE, name_, nesting_indent_, ACE_OS_Object_Manager::starting_up, ACE_Log_Msg::trace_active, and ACE_Log_Msg::tracing_enabled.

00114 {
00115   // If ACE has not yet been initialized, don't try to trace... there's
00116   // too much stuff not yet initialized.
00117   if (ACE_Trace::enable_tracing_ && !ACE_OS_Object_Manager::starting_up ())
00118     {
00119       ACE_Log_Msg *lm = ACE_LOG_MSG;
00120       if (lm->tracing_enabled ()
00121           && lm->trace_active () == 0)
00122         {
00123           lm->trace_active (1);
00124           ACE_DEBUG ((LM_TRACE,
00125                       ACE_LIB_TEXT ("%*s(%t) leaving %s\n"),
00126                       ACE_Trace::nesting_indent_ * lm->dec (),
00127                       ACE_LIB_TEXT (""),
00128                       this->name_));
00129           lm->trace_active (0);
00130         }
00131     }
00132 }


Member Function Documentation

void ACE_Trace::dump void    const
 

Dump the state of an object.

Definition at line 31 of file Trace.cpp.

00032 {
00033 }

int ACE_Trace::get_nesting_indent void    [static]
 

Get the nesting indentation level.

Definition at line 70 of file Trace.cpp.

References nesting_indent_.

Referenced by ACE_Log_Msg::log.

00071 {
00072   return ACE_Trace::nesting_indent_;
00073 }

int ACE_Trace::is_tracing void    [static]
 

Determine if tracing is enabled (return == 1) or not (== 0).

Definition at line 38 of file Trace.cpp.

References enable_tracing_.

00039 {
00040   return ACE_Trace::enable_tracing_;
00041 }

void ACE_Trace::set_nesting_indent int    indent [static]
 

Change the nesting indentation level.

Definition at line 62 of file Trace.cpp.

References nesting_indent_.

00063 {
00064   ACE_Trace::nesting_indent_ = indent;
00065 }

void ACE_Trace::start_tracing void    [static]
 

Enable the tracing facility.

Definition at line 46 of file Trace.cpp.

References enable_tracing_.

Referenced by ACE_Object_Manager::init, and ACE_Name_Options::parse_args.

00047 {
00048   ACE_Trace::enable_tracing_ = 1;
00049 }

void ACE_Trace::stop_tracing void    [static]
 

Disable the tracing facility.

Definition at line 54 of file Trace.cpp.

References enable_tracing_.

Referenced by ACE_Object_Manager::fini, and ACE_Name_Options::parse_args.

00055 {
00056   ACE_Trace::enable_tracing_ = 0;
00057 }


Member Data Documentation

int ACE_Trace::enable_tracing_ = ACE_Trace::DEFAULT_TRACING [static, private]
 

Is tracing enabled?

Definition at line 26 of file Trace.cpp.

Referenced by ACE_Trace, is_tracing, start_tracing, stop_tracing, and ~ACE_Trace.

const ACE_TCHAR* ACE_Trace::name_ [private]
 

Name of the method we are in.

Definition at line 76 of file Trace.h.

Referenced by ACE_Trace, and ~ACE_Trace.

int ACE_Trace::nesting_indent_ = ACE_Trace::DEFAULT_INDENT [static, private]
 

Keeps track of how far to indent per trace call.

Definition at line 23 of file Trace.cpp.

Referenced by ACE_Trace, get_nesting_indent, set_nesting_indent, and ~ACE_Trace.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:58:40 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002