3 // Turn off tracing for the duration of this file.
4 #if defined (ACE_NTRACE)
6 #endif /* ACE_NTRACE */
9 #include "ace/Log_Category.h"
10 #include "ace/Object_Manager_Base.h"
11 #if defined (ACE_HAS_ALLOC_HOOKS)
12 # include "ace/Malloc_Base.h"
13 #endif /* ACE_HAS_ALLOC_HOOKS */
15 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
17 // = Static initialization.
19 // Keeps track of how far to indent per trace call.
20 int ACE_Trace::nesting_indent_
= ACE_Trace::DEFAULT_INDENT
;
22 // Is tracing enabled?
23 bool ACE_Trace::enable_tracing_
= ACE_Trace::DEFAULT_TRACING
;
25 ACE_ALLOC_HOOK_DEFINE(ACE_Trace
)
28 ACE_Trace::dump () const
30 #if defined (ACE_HAS_DUMP)
31 #endif /* ACE_HAS_DUMP */
34 // Determine whether or not tracing is enabled
37 ACE_Trace::is_tracing ()
39 return ACE_Trace::enable_tracing_
;
42 // Enable the tracing facility.
45 ACE_Trace::start_tracing ()
47 ACE_Trace::enable_tracing_
= true;
50 // Disable the tracing facility.
53 ACE_Trace::stop_tracing ()
55 ACE_Trace::enable_tracing_
= false;
58 // Change the nesting indentation level.
61 ACE_Trace::set_nesting_indent (int indent
)
63 ACE_Trace::nesting_indent_
= indent
;
66 // Get the nesting indentation level.
69 ACE_Trace::get_nesting_indent ()
71 return ACE_Trace::nesting_indent_
;
74 // Perform the first part of the trace, which prints out the string N,
75 // the LINE, and the ACE_FILE as the function is entered.
77 ACE_Trace::ACE_Trace (const ACE_TCHAR
*n
,
79 const ACE_TCHAR
*file
)
81 #if defined (ACE_NLOGGING)
82 ACE_UNUSED_ARG (line
);
83 ACE_UNUSED_ARG (file
);
84 #endif /* ACE_NLOGGING */
88 // If ACE has not yet been initialized, don't try to trace... there's
89 // too much stuff not yet initialized.
90 if (ACE_Trace::enable_tracing_
&& !ACE_OS_Object_Manager::starting_up ())
92 ACE_Log_Msg
*lm
= ACE_LOG_MSG
;
93 if (lm
->tracing_enabled ()
94 && lm
->trace_active () == 0)
97 ACELIB_DEBUG ((LM_TRACE
,
98 ACE_TEXT ("%*s(%t) calling %s in file `%s' on line %d\n"),
99 ACE_Trace::nesting_indent_
* lm
->inc (),
104 lm
->trace_active (0);
109 // Perform the second part of the trace, which prints out the NAME as
110 // the function is exited.
112 ACE_Trace::~ACE_Trace ()
114 // If ACE has not yet been initialized, don't try to trace... there's
115 // too much stuff not yet initialized.
116 if (ACE_Trace::enable_tracing_
&& !ACE_OS_Object_Manager::starting_up ())
118 ACE_Log_Msg
*lm
= ACE_LOG_MSG
;
119 if (lm
->tracing_enabled ()
120 && lm
->trace_active () == 0)
122 lm
->trace_active (1);
123 ACELIB_DEBUG ((LM_TRACE
,
124 ACE_TEXT ("%*s(%t) leaving %s\n"),
125 ACE_Trace::nesting_indent_
* lm
->dec (),
128 lm
->trace_active (0);
133 ACE_END_VERSIONED_NAMESPACE_DECL