summaryrefslogtreecommitdiff
path: root/ace/Trace.h
blob: 8f6e8b2786941cb68fc70b0ece8980c722690370 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* -*- C++ -*- */
// $Id$


// ============================================================================
//
// = LIBRARY
//    ace
// 
// = FILENAME
//    Trace.h
//
// = AUTHOR
//    Doug Schmidt 
// 
// ============================================================================

#if !defined (ACE_TRACE_H)
#define ACE_TRACE_H

class ACE_Export ACE_Trace
{
  // = TITLE
  //     A C++ trace facility that keeps track of which methods are
  //     entered and exited.
  //
  // = DESCRIPTION
  //     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.
public:
  // = Initialization and termination methods.

  ACE_Trace (const ASYS_TCHAR *n, int line = 0,
             const ASYS_TCHAR *file = ASYS_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.

  ~ACE_Trace (void);
  // Perform the second part of the trace, which prints out the NAME
  // as the function is exited.

  // = Control the tracing level.
  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. 

  void dump (void) const;
  // Dump the state of an object.

private:
  // Keeps track of how deeply the call stack is nested (this is
  // maintained in thread-specific storage to ensure correctness in
  // multiple threads of control.

  const ASYS_TCHAR *name_;
  // Name of the method we are in.

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

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

#endif /* ACE_TRACE_H */