1 // $Id: Trace.cpp 80826 2008-03-04 14:51:23Z wotte $
8 "$Id: Trace.cpp 80826 2008-03-04 14:51:23Z wotte $")
10 // Turn off tracing for the duration of this file.
11 #if defined (ACE_NTRACE)
13 #endif /* ACE_NTRACE */
16 #include "ace/Log_Msg.h"
17 #include "ace/Object_Manager_Base.h"
19 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
21 // = Static initialization.
23 // Keeps track of how far to indent per trace call.
24 int ACE_Trace::nesting_indent_
= ACE_Trace::DEFAULT_INDENT
;
26 // Is tracing enabled?
27 int ACE_Trace::enable_tracing_
= ACE_Trace::DEFAULT_TRACING
;
29 ACE_ALLOC_HOOK_DEFINE(ACE_Trace
)
32 ACE_Trace::dump (void) const
34 #if defined (ACE_HAS_DUMP)
35 #endif /* ACE_HAS_DUMP */
38 // Determine whether or not tracing is enabled
41 ACE_Trace::is_tracing (void)
43 return ACE_Trace::enable_tracing_
;
46 // Enable the tracing facility.
49 ACE_Trace::start_tracing (void)
51 ACE_Trace::enable_tracing_
= 1;
54 // Disable the tracing facility.
57 ACE_Trace::stop_tracing (void)
59 ACE_Trace::enable_tracing_
= 0;
62 // Change the nesting indentation level.
65 ACE_Trace::set_nesting_indent (int indent
)
67 ACE_Trace::nesting_indent_
= indent
;
70 // Get the nesting indentation level.
73 ACE_Trace::get_nesting_indent (void)
75 return ACE_Trace::nesting_indent_
;
78 // Perform the first part of the trace, which prints out the string N,
79 // the LINE, and the ACE_FILE as the function is entered.
81 ACE_Trace::ACE_Trace (const ACE_TCHAR
*n
,
83 const ACE_TCHAR
*file
)
85 #if defined (ACE_NLOGGING)
86 ACE_UNUSED_ARG (line
);
87 ACE_UNUSED_ARG (file
);
88 #endif /* ACE_NLOGGING */
92 // If ACE has not yet been initialized, don't try to trace... there's
93 // too much stuff not yet initialized.
94 if (ACE_Trace::enable_tracing_
&& !ACE_OS_Object_Manager::starting_up ())
96 ACE_Log_Msg
*lm
= ACE_LOG_MSG
;
97 if (lm
->tracing_enabled ()
98 && lm
->trace_active () == 0)
100 lm
->trace_active (1);
101 ACE_DEBUG ((LM_TRACE
,
102 ACE_TEXT ("%*s(%t) calling %s in file `%s' on line %d\n"),
103 ACE_Trace::nesting_indent_
* lm
->inc (),
108 lm
->trace_active (0);
113 // Perform the second part of the trace, which prints out the NAME as
114 // the function is exited.
116 ACE_Trace::~ACE_Trace (void)
118 // If ACE has not yet been initialized, don't try to trace... there's
119 // too much stuff not yet initialized.
120 if (ACE_Trace::enable_tracing_
&& !ACE_OS_Object_Manager::starting_up ())
122 ACE_Log_Msg
*lm
= ACE_LOG_MSG
;
123 if (lm
->tracing_enabled ()
124 && lm
->trace_active () == 0)
126 lm
->trace_active (1);
127 ACE_DEBUG ((LM_TRACE
,
128 ACE_TEXT ("%*s(%t) leaving %s\n"),
129 ACE_Trace::nesting_indent_
* lm
->dec (),
132 lm
->trace_active (0);
137 ACE_END_VERSIONED_NAMESPACE_DECL