Trace.cpp

Go to the documentation of this file.
00001 // Trace.cpp,v 4.25 2005/10/28 23:55:10 ossama Exp
00002 
00003 
00004 #include "ace/Trace.h"
00005 
00006 ACE_RCSID (ace,
00007            Trace,
00008            "Trace.cpp,v 4.25 2005/10/28 23:55:10 ossama Exp")
00009 
00010 // Turn off tracing for the duration of this file.
00011 #if defined (ACE_NTRACE)
00012 #undef ACE_NTRACE
00013 #endif /* ACE_NTRACE */
00014 #define ACE_NTRACE 1
00015 
00016 #include "ace/Log_Msg.h"
00017 #include "ace/Object_Manager_Base.h"
00018 
00019 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00020 
00021 // = Static initialization.
00022 
00023 // Keeps track of how far to indent per trace call.
00024 int ACE_Trace::nesting_indent_ = ACE_Trace::DEFAULT_INDENT;
00025 
00026 // Is tracing enabled?
00027 int ACE_Trace::enable_tracing_ = ACE_Trace::DEFAULT_TRACING;
00028 
00029 ACE_ALLOC_HOOK_DEFINE(ACE_Trace)
00030 
00031 void
00032 ACE_Trace::dump (void) const
00033 {
00034 #if defined (ACE_HAS_DUMP)
00035 #endif /* ACE_HAS_DUMP */
00036 }
00037 
00038 // Determine whether or not tracing is enabled
00039 
00040 int
00041 ACE_Trace::is_tracing (void)
00042 {
00043   return ACE_Trace::enable_tracing_;
00044 }
00045 
00046 // Enable the tracing facility.
00047 
00048 void
00049 ACE_Trace::start_tracing (void)
00050 {
00051   ACE_Trace::enable_tracing_ = 1;
00052 }
00053 
00054 // Disable the tracing facility.
00055 
00056 void
00057 ACE_Trace::stop_tracing (void)
00058 {
00059   ACE_Trace::enable_tracing_ = 0;
00060 }
00061 
00062 // Change the nesting indentation level.
00063 
00064 void
00065 ACE_Trace::set_nesting_indent (int indent)
00066 {
00067   ACE_Trace::nesting_indent_ = indent;
00068 }
00069 
00070 // Get the nesting indentation level.
00071 
00072 int
00073 ACE_Trace::get_nesting_indent (void)
00074 {
00075   return ACE_Trace::nesting_indent_;
00076 }
00077 
00078 // Perform the first part of the trace, which prints out the string N,
00079 // the LINE, and the ACE_FILE as the function is entered.
00080 
00081 ACE_Trace::ACE_Trace (const ACE_TCHAR *n,
00082                       int line,
00083                       const ACE_TCHAR *file)
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_LIB_TEXT ("%*s(%t) calling %s in file `%s' on line %d\n"),
00103                       ACE_Trace::nesting_indent_ * lm->inc (),
00104                       ACE_LIB_TEXT (""),
00105                       this->name_,
00106                       file,
00107                       line));
00108           lm->trace_active (0);
00109         }
00110     }
00111 }
00112 
00113 // Perform the second part of the trace, which prints out the NAME as
00114 // the function is exited.
00115 
00116 ACE_Trace::~ACE_Trace (void)
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_LIB_TEXT ("%*s(%t) leaving %s\n"),
00129                       ACE_Trace::nesting_indent_ * lm->dec (),
00130                       ACE_LIB_TEXT (""),
00131                       this->name_));
00132           lm->trace_active (0);
00133         }
00134     }
00135 }
00136 
00137 ACE_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 09:42:08 2006 for ACE by doxygen 1.3.6