Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

147 lines
2.5 KiB

  1. /*++
  2. Copyright (c) 1998-1999 Microsoft Corporation
  3. All rights reserved.
  4. Module Name:
  5. dbgtrace.hxx
  6. Abstract:
  7. Debug tracer routines. Tracer routines are used to
  8. display a debugging message on entry and exit of
  9. a subroutine call. Note this class relies on the
  10. debug message class. A user must use and initialize
  11. the debug messages for tracer to work.
  12. Author:
  13. Steve Kiraly (SteveKi) 4-Jun-1996
  14. Revision History:
  15. --*/
  16. #include "precomp.hxx"
  17. #pragma hdrstop
  18. //
  19. // Static indent count for indenting.
  20. //
  21. UINT TDebugTracer::m_uLev = 0;
  22. /*++
  23. Routine Name:
  24. TDebugTracer
  25. Routine Description:
  26. Construct a trace class and emit a trace message.
  27. Arguments:
  28. pszMessage - Pointer to trace message which will be displayed.
  29. Return Value:
  30. Nothing.
  31. --*/
  32. TDebugTracer::
  33. TDebugTracer(
  34. IN LPCSTR pszMessage
  35. )
  36. {
  37. m_strMsg.pszNarrow = pszMessage;
  38. m_bAnsi = TRUE;
  39. TDebugMsg_Msg( kDbgTrace|kDbgNoFileInfo,
  40. NULL,
  41. 0,
  42. NULL,
  43. TDebugMsg_Fmt( "%*sEnter %s\n", m_uLev * 4, m_uLev ? " " : "", m_strMsg.pszNarrow ) );
  44. m_uLev++;
  45. }
  46. /*++
  47. Routine Name:
  48. TDebugTracer
  49. Routine Description:
  50. Construct a trace class and emit a trace message.
  51. Arguments:
  52. pszMessage - Pointer to trace message which will be displayed.
  53. Return Value:
  54. Nothing.
  55. --*/
  56. TDebugTracer::
  57. TDebugTracer(
  58. IN LPCWSTR pszMessage
  59. )
  60. {
  61. m_strMsg.pszWide = pszMessage;
  62. m_bAnsi = FALSE;
  63. TDebugMsg_Msg( kDbgTrace|kDbgNoFileInfo,
  64. NULL,
  65. 0,
  66. NULL,
  67. TDebugMsg_Fmt( L"%*sEnter %s\n", m_uLev * 4, m_uLev ? L" " : L"", m_strMsg.pszWide ) );
  68. ++m_uLev;
  69. }
  70. /*++
  71. Routine Name:
  72. ~TDebugTracer
  73. Routine Description:
  74. Emit a trace message when the trace class falls out of scope.
  75. Arguments:
  76. None.
  77. Return Value:
  78. Nothing.
  79. --*/
  80. TDebugTracer::
  81. ~TDebugTracer(
  82. VOID
  83. )
  84. {
  85. --m_uLev;
  86. if( m_bAnsi )
  87. {
  88. TDebugMsg_Msg( kDbgTrace|kDbgNoFileInfo,
  89. NULL,
  90. 0,
  91. NULL,
  92. TDebugMsg_Fmt( "%*sLeave %s\n", m_uLev * 4, m_uLev ? " " : "", m_strMsg.pszNarrow ) );
  93. }
  94. else
  95. {
  96. TDebugMsg_Msg( kDbgTrace|kDbgNoFileInfo,
  97. NULL,
  98. 0,
  99. NULL,
  100. TDebugMsg_Fmt( L"%*sLeave %s\n", m_uLev * 4, m_uLev ? L" " : L"", m_strMsg.pszWide ) );
  101. }
  102. }