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.

168 lines
5.0 KiB

  1. //
  2. // Copyright (c) 1997-2001 Microsoft Corporation, All Rights Reserved
  3. //
  4. // ***************************************************************************
  5. //
  6. // Original Author: Rajesh Rao
  7. //
  8. // $Author: rajeshr $
  9. // $Date: 6/11/98 4:43p $
  10. // $Workfile:log.h $
  11. //
  12. // $Modtime: 6/11/98 11:21a $
  13. // $Revision: 1 $
  14. // $Nokeywords: $
  15. //
  16. //
  17. // Description: Contains the declaration for the Logging object which supplies
  18. // basic thread-safe logging capabilities. The behaviour of this log object depends on
  19. // 3 keys in the registry under a root key whose path is supplied in the construction
  20. // of this object. The 3 keys are:
  21. // File: The path to the file where the logging is done
  22. // Enabled: 1 if logging is enabled, any other value disables logging
  23. // Level: Severity level. Only messages tagged with severity levels greater than
  24. // or equal to this level are logged/
  25. //
  26. //***************************************************************************
  27. /////////////////////////////////////////////////////////////////////////
  28. class CDsLog : ProvDebugLog
  29. {
  30. public:
  31. //***************************************************************************
  32. //
  33. // CDsLog::CDsLog
  34. //
  35. // Purpose: Contructs an empty CDsLog object.
  36. //
  37. // Parameters:
  38. // None
  39. //
  40. //***************************************************************************
  41. CDsLog(const TCHAR *a_DebugComponent );
  42. //***************************************************************************
  43. //
  44. // CDsLog::~CDsLog
  45. //
  46. // Purpose: Destructor
  47. //
  48. //
  49. //***************************************************************************
  50. virtual ~CDsLog();
  51. //***************************************************************************
  52. //
  53. // CDsLog::LogMessage
  54. //
  55. // Purpose: Initialise it by supplying the registry key that stores the
  56. // configuration information
  57. //
  58. // Parameters:
  59. // lpszRegistrySubTreeRoot: The root of the subtree from which the configuration
  60. // values ("File", "Enabled" and "Level") are read
  61. //
  62. // Return Value:
  63. // TRUE If the object was initialized successfully. else, FALSE.
  64. //
  65. //***************************************************************************
  66. BOOLEAN Initialise(LPCWSTR lpRegistryRoot);
  67. //***************************************************************************
  68. //
  69. // CDsLog::LogMessage
  70. //
  71. // Purpose: Initialise it by supplying the values for File, Level and Enabled keys
  72. //
  73. // Parameters:
  74. // lpszFileName: The name of the file to which log messages are written
  75. // bEnabled: Whether ;pgging is enabled to start with
  76. // iLevel : The severity level. Any messages at or above this level are logged.
  77. //
  78. // Return Value:
  79. // TRUE if successfully initialized. Else, FALSE
  80. //
  81. //***************************************************************************
  82. BOOLEAN Initialise(LPCWSTR lpszFileName, BOOLEAN bEnabled, UINT iLevel);
  83. //***************************************************************************
  84. //
  85. // CDsLog::LogMessage
  86. //
  87. // Purpose: Logs a message. The actual message is written on to the log file
  88. // only if logging has been enabled and the severity level of the message is
  89. // greater than the severity level currently logged
  90. //
  91. // Parameters:
  92. // iLevel : The severity level of this message
  93. // lpszMessage : The message which is formatted according to the
  94. // standard printf() format
  95. // The rest of the arguments required for above string to be pronted follow
  96. //
  97. // Return Value:
  98. // None
  99. //
  100. //***************************************************************************
  101. void LogMessage(UINT iLevel, LPCWSTR lpszMessage, ...);
  102. // The various severity levels
  103. enum SeverityLevels
  104. {
  105. NONE,
  106. INFORMATION,
  107. WARNING,
  108. FATAL
  109. };
  110. private:
  111. //***************************************************************************
  112. //
  113. // CDsLog::WriteInitialMessage
  114. //
  115. // Purpose: Writes the time the log was created into the log file
  116. //
  117. // Parameters:
  118. //
  119. // Return Value: None
  120. //
  121. //***************************************************************************
  122. void WriteInitialMessage();
  123. //***************************************************************************
  124. //
  125. // CDsLog::GetRegistryValues
  126. //
  127. // Purpose: Reads the registry values and fills in the members.
  128. //
  129. // Parameters:
  130. // lpszRegistrySubTreeRoot: The root of the subtree from which the configuration
  131. // values ("File", "Enabled" and "Level") are read
  132. //
  133. // Return Value:
  134. // TRUE If the reading of the registry was done successflly, FALSE otherwise
  135. //
  136. //***************************************************************************
  137. BOOLEAN GetRegistryValues(LPCWSTR lpRegistryRoot);
  138. // The Log File name
  139. LPTSTR m_lpszLogFileName;
  140. // Pointer to the log file
  141. ProvDebugLog *m_pProvLog;
  142. // Logging level till which logging is enabled
  143. UINT m_iLevel;
  144. // Whether logging is enabled
  145. BOOLEAN m_bEnabled;
  146. // The key in the registry below which the File, Enabled and Type keys are
  147. // defined
  148. LPTSTR m_lpszRegistryRoot;
  149. // Literals for "FILE", "ENABLED" and "TYPE"
  150. static LPCTSTR FILE_STRING;
  151. static LPCTSTR ENABLED_STRING;
  152. static LPCTSTR LEVEL_STRING;
  153. static LPCTSTR ONE_STRING;
  154. };