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.

264 lines
6.3 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Abstract:
  4. Implements new log engine.
  5. Author:
  6. Souren Aghajanyan (sourenag) 24-Sep-2001
  7. Revision History:
  8. <alias> <date> <comments>
  9. --*/
  10. #pragma once
  11. #ifndef MY_EXTERN_C
  12. #ifdef __cplusplus
  13. #define MY_EXTERN_C extern "C"
  14. #else
  15. #define MY_EXTERN_C extern
  16. #endif
  17. #endif
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. //
  22. // Constants
  23. //
  24. #if defined(DBG) || defined(_DEBUG)
  25. #undef DEBUG
  26. #define DEBUG
  27. #endif
  28. #define MAX_LOG_NAME 256
  29. #ifndef STDMETHODCALLTYPE
  30. #define STDMETHODCALLTYPE __stdcall
  31. #endif
  32. typedef enum tagLOG_PROVIDER_TYPE{
  33. LOG_FILTER_TYPE,
  34. LOG_FORMATTER_TYPE,
  35. LOG_DEVICE_TYPE
  36. }LOG_PROVIDER_TYPE, *PLOG_PROVIDER_TYPE;
  37. typedef enum tagLOGRESULT{
  38. // for all types of providers
  39. logError = FALSE,
  40. logOk = TRUE,
  41. // for filter&formatter
  42. logContinue = logOk,
  43. logDoNotContinue,
  44. logBreakPoint,
  45. logAbortProcess,
  46. // for device
  47. logAlreadyExist
  48. }LOGRESULT, *PLOGRESULT;
  49. typedef enum tagLOGTYPE{
  50. LT_SZ,
  51. LT_DWORD,
  52. LT_BINARY,
  53. }LOGTYPE, *PLOGTYPE;
  54. typedef struct tagLOG_FIELD_INFO
  55. {
  56. LOGTYPE Type;
  57. BOOL bMandatory;
  58. WCHAR Name[MAX_LOG_NAME];
  59. }LOG_FIELD_INFO, *PLOG_FIELD_INFO;
  60. typedef struct tagLOG_VALUE{
  61. LOGTYPE Type;
  62. union{
  63. struct BinaryValue{
  64. PBYTE Buffer;
  65. DWORD Size;
  66. }Binary;
  67. DWORD Dword;
  68. PCWSTR String;
  69. PVOID PVoid;
  70. };
  71. }LOG_VALUE, *PLOG_VALUE;
  72. typedef struct tagLOG_FIELD_VALUE{
  73. WCHAR Name[MAX_LOG_NAME];
  74. BOOL bMandatory;
  75. LOG_VALUE Value;
  76. }LOG_FIELD_VALUE, *PLOG_FIELD_VALUE;
  77. typedef enum tagDEVICE_PROV_FLAGS{
  78. DEVICE_WRITE_THROUGH = 0x1,
  79. DEVICE_CREATE_NEW = 0x2
  80. }DEVICE_PROV_FLAGS, *PDEVICE_PROV_FLAGS;
  81. typedef struct tagLOG_DEVICE_PROV_INIT_DATA{
  82. PCWSTR PathName;
  83. DWORD dwFlags;
  84. DWORD dwReserved1;
  85. DWORD dwReserved2;
  86. }LOG_DEVICE_PROV_INIT_DATA, *PLOG_DEVICE_PROV_INIT_DATA;
  87. typedef enum tagLOG_SETUPLOG_SEVERITY{
  88. LOG_ASSERT = 0,
  89. LOG_FATAL_ERROR = 1,
  90. LOG_ERROR = 2,
  91. LOG_WARNING = 3,
  92. LOG_INFO = 4,
  93. DBG_ASSERT = 101,
  94. DBG_NAUSEA = 102,
  95. DBG_INFO = 103,
  96. DBG_VERBOSE = 104,
  97. DBG_STATS = 105,
  98. DBG_WARNING = 106,
  99. DBG_ERROR = 107,
  100. DBG_WHOOPS = 108,
  101. DBG_TRACK = 109,
  102. DBG_TIME = 111
  103. }LOG_SETUPLOG_SEVERITY, *PLOG_SETUPLOG_SEVERITY;
  104. typedef struct tagLOG_SETUPLOG_FORMAT_PROV_INIT_DATA{
  105. PCWSTR SeverityFieldName;
  106. PCWSTR MessageFieldName;
  107. DWORD dwFlags;
  108. }LOG_SETUPLOG_FORMAT_PROV_INIT_DATA, *PLOG_SETUPLOG_FORMAT_PROV_INIT_DATA;
  109. typedef struct tagLOG_SETUPLOG_FILTER_PROV_INIT_DATA{
  110. PCWSTR FieldName;
  111. LOG_SETUPLOG_SEVERITY SeverityThreshold;
  112. BOOL SuppressDebugMessages;
  113. }LOG_SETUPLOG_FILTER_PROV_INIT_DATA, *PLOG_SETUPLOG_FILTER_PROV_INIT_DATA;
  114. typedef struct tagLOG_DEBUG_FORMAT_AND_DEVICE_PROV_INIT_DATA{
  115. PCWSTR SeverityFieldName;
  116. PCWSTR MessageFieldName;
  117. PCWSTR ConditionFieldName;
  118. PCWSTR SourceLineFieldName;
  119. PCWSTR SourceFileFieldName;
  120. PCWSTR SourceFunctionFieldName;
  121. }LOG_DEBUG_FORMAT_AND_DEVICE_PROV_INIT_DATA, *PLOG_DEBUG_FORMAT_AND_DEVICE_PROV_INIT_DATA;
  122. MY_EXTERN_C const GUID GUID_STANDARD_SETUPLOG_FILTER;
  123. MY_EXTERN_C const GUID GUID_STANDARD_SETUPLOG_FORMATTER;
  124. MY_EXTERN_C const GUID GUID_FILE_DEVICE;
  125. MY_EXTERN_C const GUID GUID_DEBUG_FORMATTER_AND_DEVICE;
  126. MY_EXTERN_C const GUID GUID_DEBUG_FILTER;
  127. MY_EXTERN_C const GUID GUID_XML_FORMATTER;
  128. MY_EXTERN_C
  129. BOOL
  130. LogRegisterStockProviders(
  131. VOID
  132. );
  133. MY_EXTERN_C
  134. BOOL
  135. LogUnRegisterStockProviders(
  136. VOID
  137. );
  138. //////////////////////////////////////////////////////////////////////////////////////
  139. //Interface ILogManager
  140. #if defined(__cplusplus) && !defined(CINTERFACE)
  141. class ILogManager
  142. {
  143. public:
  144. virtual BOOL STDMETHODCALLTYPE AddStack(const GUID *guidFilter,
  145. PVOID pFilterData,
  146. const GUID *guidFormater,
  147. PVOID pFormaterData,
  148. const GUID *guidDevice,
  149. PVOID pDeviceData,
  150. PVOID *pvHandle) = 0;
  151. virtual BOOL STDMETHODCALLTYPE RemoveStack(PVOID pvHandle) = 0;
  152. virtual LOGRESULT STDMETHODCALLTYPE LogA(UINT NumberOfFieldsToLog, ...) = 0;
  153. virtual LOGRESULT STDMETHODCALLTYPE LogW(UINT NumberOfFieldsToLog, ...) = 0;
  154. };
  155. #ifdef UNICODE
  156. #define Log LogW
  157. #else
  158. #define Log LogA
  159. #endif
  160. #else
  161. typedef struct ILogManagerVtbl;
  162. typedef struct ILogManager
  163. {
  164. const struct ILogManagerVtbl * pVtbl;
  165. }ILogManager;
  166. typedef struct ILogManagerVtbl
  167. {
  168. BOOL (STDMETHODCALLTYPE *AddStack)(
  169. ILogManager * This,
  170. const GUID *guidFilter,
  171. PVOID pFilterData,
  172. const GUID *guidFormater,
  173. PVOID pFormaterData,
  174. const GUID *guidDevice,
  175. PVOID pDeviceData,
  176. PVOID *pvHandle);
  177. BOOL (STDMETHODCALLTYPE *RemoveStack)(
  178. ILogManager * This,
  179. DWORD pvHandle);
  180. LOGRESULT (STDMETHODCALLTYPE *LogA)(
  181. ILogManager * This,
  182. UINT NumberOfFieldsToLog,
  183. ...);
  184. LOGRESULT (STDMETHODCALLTYPE *LogW)(
  185. ILogManager * This,
  186. UINT NumberOfFieldsToLog,
  187. ...);
  188. } ILogManagerVtbl;
  189. #define ILogManager_AddStack(This,guidFilter,pFilterData,guidFormater,pFormaterData,guidDevice,pDeviceData,pvHandle) \
  190. (This)->pVtbl->AddStack(This,guidFilter,pFilterData,guidFormater,pFormaterData,guidDevice,pDeviceData,pvHandle)
  191. #define ILogManager_RemoveStack(This,pvHandle) \
  192. (This)->pVtbl->RemoveStack(This,pvHandle)
  193. #define ILogManager_Log(This) (This)->pVtbl->Log
  194. #define ILogManager(This) ((This)->pVtbl)
  195. #ifdef UNICODE
  196. #define Log LogW
  197. #else
  198. #define Log LogA
  199. #endif
  200. #endif
  201. ILogManager *
  202. LogCreateLog(
  203. IN PCWSTR pLogName,
  204. IN PLOG_FIELD_INFO pFields,
  205. IN UINT NumberOfFields
  206. );
  207. VOID
  208. LogDestroyLog(
  209. IN ILogManager * pLog
  210. );
  211. #ifdef __cplusplus
  212. }
  213. #endif