Leaked source code of windows server 2003
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.

131 lines
2.6 KiB

  1. #ifndef _W3_TRACE_LOG_
  2. #define _W3_TRACE_LOG_
  3. class W3_TRACE_LOG;
  4. class IRTL_DLLEXP W3_TRACE_LOG_FACTORY
  5. {
  6. public:
  7. static HRESULT CreateTraceLogFactory(W3_TRACE_LOG_FACTORY ** ppLogFactory, HANDLE hFile);
  8. VOID DestroyTraceLogFactory();
  9. HRESULT CreateTraceLog(W3_TRACE_LOG ** ppLog);
  10. HRESULT AppendData(LPVOID pvData, ULONG cbSize);
  11. private:
  12. W3_TRACE_LOG_FACTORY() { }
  13. ~W3_TRACE_LOG_FACTORY() { }
  14. //
  15. // periodic callback method
  16. //
  17. static VOID CALLBACK TimerCallback(PVOID lpParameter, BOOLEAN TimerOrWaitFired);
  18. //
  19. // Write the internal buffer out to file
  20. //
  21. HRESULT CommitToFile();
  22. //
  23. // Handle to file to write to
  24. //
  25. HANDLE m_hFile;
  26. //
  27. // Handle to timer for time based scavenging
  28. //
  29. HANDLE m_hTimer;
  30. //
  31. // Size of buffer in bytes
  32. //
  33. ULONG m_ulBufferSizeInBytes;
  34. //
  35. // Data storage and allocation slop management
  36. //
  37. BUFFER m_Buffer;
  38. //
  39. // synchronization method for writing to factory
  40. //
  41. CRITICAL_SECTION m_cs;
  42. //
  43. // flag that m_cs was initialized
  44. //
  45. BOOL m_fInitCs;
  46. };
  47. class IRTL_DLLEXP W3_TRACE_LOG
  48. {
  49. public:
  50. W3_TRACE_LOG(W3_TRACE_LOG_FACTORY * pLogFactory);
  51. VOID DestroyTraceLog();
  52. VOID SetBlocking(BOOL fBlock);
  53. VOID SetBuffering(BOOL fBuffer);
  54. VOID ClearBuffer();
  55. VOID Indent() { InterlockedIncrement(&m_lIndentLevel); }
  56. VOID Undent() { InterlockedDecrement(&m_lIndentLevel); }
  57. HRESULT Trace(LPCWSTR pszFormat, ...);
  58. private:
  59. W3_TRACE_LOG();
  60. ~W3_TRACE_LOG();
  61. //
  62. // back pointer to logfactory
  63. //
  64. W3_TRACE_LOG_FACTORY * m_pLogFactory;
  65. //
  66. // Whether or not writes to the local log should be synchronized
  67. //
  68. BOOL m_fBlock;
  69. //
  70. // synchronization method for local log writes (if needed)
  71. //
  72. CRITICAL_SECTION m_cs;
  73. //
  74. // if criticalsection has been initialized
  75. //
  76. BOOL m_fCritSecInitialized;
  77. //
  78. // Flag whether or not to buffer writes to this W3_TRACE_LOG
  79. // TRUE (default) means buffer
  80. // FALSE means write to W3_TRACE_LOG_FACTORY immediately
  81. //
  82. BOOL m_fBuffer;
  83. //
  84. // Size of the buffer in bytes
  85. //
  86. ULONG m_ulBufferSizeInBytes;
  87. //
  88. // Number of indents to place in front of traces
  89. //
  90. LONG m_lIndentLevel;
  91. //
  92. // BUFFER for storage of data, and sizing slop management
  93. //
  94. BUFFER m_Buffer;
  95. };
  96. #endif // _W3_TRACE_LOG_