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

Trace.cpp

Go to the documentation of this file.
00001 #include "ace_pch.h"
00002 // $Id: Trace.cpp,v 1.1.1.4.2.1 2003/03/13 19:44:23 chad Exp $
00003 
00004 
00005 #include "ace/Trace.h"
00006 
00007 ACE_RCSID (ace,
00008            Trace,
00009            "$Id: Trace.cpp,v 1.1.1.4.2.1 2003/03/13 19:44:23 chad Exp $")
00010 
00011 // Turn off tracing for the duration of this file.
00012 #if defined (ACE_NTRACE)
00013 #undef ACE_NTRACE
00014 #endif /* ACE_NTRACE */
00015 #define ACE_NTRACE 1
00016 
00017 #include "ace/Log_Msg.h"
00018 #include "ace/OS.h"
00019 
00020 // = Static initialization.
00021 
00022 // Keeps track of how far to indent per trace call.
00023 int ACE_Trace::nesting_indent_ = ACE_Trace::DEFAULT_INDENT;
00024 
00025 // Is tracing enabled?
00026 int ACE_Trace::enable_tracing_ = ACE_Trace::DEFAULT_TRACING;
00027 
00028 ACE_ALLOC_HOOK_DEFINE(ACE_Trace)
00029 
00030 void
00031 ACE_Trace::dump (void) const
00032 {
00033 }
00034 
00035 // Determine whether or not tracing is enabled
00036 
00037 int
00038 ACE_Trace::is_tracing (void)
00039 {
00040   return ACE_Trace::enable_tracing_;
00041 }
00042 
00043 // Enable the tracing facility.
00044 
00045 void
00046 ACE_Trace::start_tracing (void)
00047 {
00048   ACE_Trace::enable_tracing_ = 1;
00049 }
00050 
00051 // Disable the tracing facility.
00052 
00053 void
00054 ACE_Trace::stop_tracing (void)
00055 {
00056   ACE_Trace::enable_tracing_ = 0;
00057 }
00058 
00059 // Change the nesting indentation level.
00060 
00061 void
00062 ACE_Trace::set_nesting_indent (int indent)
00063 {
00064   ACE_Trace::nesting_indent_ = indent;
00065 }
00066 
00067 // Get the nesting indentation level.
00068 
00069 int
00070 ACE_Trace::get_nesting_indent (void)
00071 {
00072   return ACE_Trace::nesting_indent_;
00073 }
00074 
00075 // Perform the first part of the trace, which prints out the string N,
00076 // the LINE, and the ACE_FILE as the function is entered.
00077 
00078 ACE_Trace::ACE_Trace (const ACE_TCHAR *n,
00079                       int line,
00080                       const ACE_TCHAR *file)
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 }
00109 
00110 // Perform the second part of the trace, which prints out the NAME as
00111 // the function is exited.
00112 
00113 ACE_Trace::~ACE_Trace (void)
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 }

Generated on Mon Jun 16 11:21:59 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002