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 Member Functions

 ACE_Trace (const ACE_TCHAR *n, int line=0, const ACE_TCHAR *file=ACE_TEXT(""))
 ~ACE_Trace (void)
void dump (void) const
 Dump the state of an object.

Static Public Member Functions

static int is_tracing (void)
 Determine if tracing is enabled (return == 1) or not (== 0).
static void start_tracing (void)
 Enable the tracing facility.
static void stop_tracing (void)
 Disable the tracing facility.
static void set_nesting_indent (int indent)
 Change the nesting indentation level.
static int get_nesting_indent (void)
 Get the nesting indentation level.

Private Types

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

Private Attributes

const ACE_TCHARname_
 Name of the method we are in.

Static Private Attributes

static int nesting_indent_
 Keeps track of how far to indent per trace call.
static int enable_tracing_
 Is tracing enabled?


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.

Enumerator:
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_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 81 of file Trace.cpp.

References ACE_DEBUG, ACE_LOG_MSG, ACE_TEXT, ACE_Log_Msg::inc(), LM_TRACE, name_, ACE_OS_Object_Manager::starting_up(), ACE_Log_Msg::trace_active(), and ACE_Log_Msg::tracing_enabled().

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

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 116 of file Trace.cpp.

References ACE_DEBUG, ACE_LOG_MSG, ACE_TEXT, ACE_Log_Msg::dec(), LM_TRACE, name_, ACE_OS_Object_Manager::starting_up(), ACE_Log_Msg::trace_active(), and ACE_Log_Msg::tracing_enabled().

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


Member Function Documentation

void ACE_Trace::dump ( void   )  const

Dump the state of an object.

Definition at line 32 of file Trace.cpp.

00033 {
00034 #if defined (ACE_HAS_DUMP)
00035 #endif /* ACE_HAS_DUMP */
00036 }

int ACE_Trace::get_nesting_indent ( void   )  [static]

Get the nesting indentation level.

Definition at line 73 of file Trace.cpp.

Referenced by ACE_Log_Msg::log().

00074 {
00075   return ACE_Trace::nesting_indent_;
00076 }

int ACE_Trace::is_tracing ( void   )  [static]

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

Definition at line 41 of file Trace.cpp.

00042 {
00043   return ACE_Trace::enable_tracing_;
00044 }

void ACE_Trace::set_nesting_indent ( int  indent  )  [static]

Change the nesting indentation level.

Definition at line 65 of file Trace.cpp.

00066 {
00067   ACE_Trace::nesting_indent_ = indent;
00068 }

void ACE_Trace::start_tracing ( void   )  [static]

Enable the tracing facility.

Definition at line 49 of file Trace.cpp.

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

00050 {
00051   ACE_Trace::enable_tracing_ = 1;
00052 }

void ACE_Trace::stop_tracing ( void   )  [static]

Disable the tracing facility.

Definition at line 57 of file Trace.cpp.

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

00058 {
00059   ACE_Trace::enable_tracing_ = 0;
00060 }


Member Data Documentation

int ACE_Trace::enable_tracing_ [static, private]

Is tracing enabled?

Definition at line 82 of file Trace.h.

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_ [static, private]

Keeps track of how far to indent per trace call.

Definition at line 79 of file Trace.h.


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:35:49 2010 for ACE by  doxygen 1.4.7