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.

219 lines
6.1 KiB

  1. //***************************************************************************
  2. //
  3. // PROVLOG.H
  4. //
  5. // Module: OLE MS PROVIDER FRAMEWORK
  6. //
  7. // Copyright (c) 1996-2001 Microsoft Corporation, All Rights Reserved
  8. //
  9. //***************************************************************************
  10. #ifndef __PROVLOG_H
  11. #define __PROVLOG_H
  12. #include <wbemutil.h>
  13. #ifdef PROVDEBUG_INIT
  14. class __declspec ( dllexport ) ProvDebugLog
  15. #else
  16. class __declspec ( dllimport ) ProvDebugLog
  17. #endif
  18. {
  19. private:
  20. char m_Caller ;
  21. protected:
  22. public:
  23. /*************************************************************************
  24. * There are 3 functions to write to a log file, which may be used in accordance with the following rules:
  25. *
  26. * 1. The user always knows whether he is writing to an ANSI file or a Unicode file, and he
  27. * has to make sure this holds good in the rules 2, 3 and 4 below. This will be changed later to
  28. * make it more flowxible to the user.
  29. * 2. Write() takes TCHAR arguments and the function will write and ANSI or Unicode string
  30. * to the log file depending on what TCHAR maps to, in the compilation.
  31. * 3. WriteW() takes WCHAR arguments only, and expects that the file being written to is a Unicode file.
  32. * 4. WriteA() takes char arguments only, and expects that the file being written to is an ANSI file.
  33. *
  34. ****************************************************************/
  35. void Write ( const TCHAR *a_DebugFormatString , ... ) ;
  36. void WriteFileAndLine ( const TCHAR *a_File , const ULONG a_Line , const TCHAR *a_DebugFormatString , ... ) ;
  37. void WriteFileAndLine ( const char *a_File , const ULONG a_Line , const wchar_t *a_DebugFormatString , ... );
  38. void WriteW ( const WCHAR *a_DebugFormatString , ... ) ;
  39. void WriteFileAndLineW ( const WCHAR *a_File , const ULONG a_Line , const WCHAR *a_DebugFormatString , ... ) ;
  40. void WriteA ( const char *a_DebugFormatString , ... ) ;
  41. void WriteFileAndLineA ( const char *a_File , const ULONG a_Line , const char *a_DebugFormatString , ... ) ;
  42. ProvDebugLog ( char Caller ):m_Caller(Caller)
  43. {
  44. };
  45. BOOL GetLogging()
  46. {
  47. if (GetLoggingLevelEnabled() == 2)
  48. return TRUE;
  49. else
  50. return FALSE;
  51. };
  52. DWORD GetLevel(){ return 32768-1; };
  53. static BOOL Startup () ;
  54. static void Closedown () ;
  55. static long s_ReferenceCount ;
  56. static ProvDebugLog s_aLogs[LOG_MAX_PROV];
  57. static ProvDebugLog * s_ProvDebugLog;
  58. static ProvDebugLog * GetProvDebugLog(char Caller)
  59. {
  60. if (Caller > LOG_MAX_PROV) return NULL;
  61. return &s_aLogs[Caller];
  62. };
  63. } ;
  64. #define DebugMacro(a) { \
  65. \
  66. if ( ProvDebugLog :: s_ProvDebugLog && ProvDebugLog :: s_ProvDebugLog->GetLogging () ) \
  67. { \
  68. {a ; } \
  69. } \
  70. }
  71. #define DebugMacro0(a) { \
  72. \
  73. if ( ProvDebugLog :: s_ProvDebugLog && ProvDebugLog :: s_ProvDebugLog->GetLogging () && ( ProvDebugLog :: s_ProvDebugLog->GetLevel () & 1 ) ) \
  74. { \
  75. {a ; } \
  76. } \
  77. }
  78. #define DebugMacro1(a) { \
  79. \
  80. if ( ProvDebugLog :: s_ProvDebugLog && ProvDebugLog :: s_ProvDebugLog->GetLogging () && ( ProvDebugLog :: s_ProvDebugLog->GetLevel () & 2 ) ) \
  81. { \
  82. {a ; } \
  83. } \
  84. }
  85. #define DebugMacro2(a) { \
  86. \
  87. if ( ProvDebugLog :: s_ProvDebugLog && ProvDebugLog :: s_ProvDebugLog->GetLogging () && ( ProvDebugLog :: s_ProvDebugLog->GetLevel () & 4 ) ) \
  88. { \
  89. {a ; } \
  90. } \
  91. }
  92. #define DebugMacro3(a) { \
  93. \
  94. if ( ProvDebugLog :: s_ProvDebugLog && ProvDebugLog :: s_ProvDebugLog->GetLogging () && ( ProvDebugLog :: s_ProvDebugLog->GetLevel () & 8 ) ) \
  95. { \
  96. {a ; } \
  97. } \
  98. }
  99. #define DebugMacro4(a) { \
  100. \
  101. if ( ProvDebugLog :: s_ProvDebugLog && ProvDebugLog :: s_ProvDebugLog->GetLogging () && ( ProvDebugLog :: s_ProvDebugLog->GetLevel () & 16 ) ) \
  102. { \
  103. {a ; } \
  104. } \
  105. }
  106. #define DebugMacro5(a) { \
  107. \
  108. if ( ProvDebugLog :: s_ProvDebugLog && ProvDebugLog :: s_ProvDebugLog->GetLogging () && ( ProvDebugLog :: s_ProvDebugLog->GetLevel () & 32 ) ) \
  109. { \
  110. {a ; } \
  111. } \
  112. }
  113. #define DebugMacro6(a) { \
  114. \
  115. if ( ProvDebugLog :: s_ProvDebugLog && ProvDebugLog :: s_ProvDebugLog->GetLogging () && ( ProvDebugLog :: s_ProvDebugLog->GetLevel () & 64 ) ) \
  116. { \
  117. {a ; } \
  118. } \
  119. }
  120. #define DebugMacro7(a) { \
  121. \
  122. if ( ProvDebugLog :: s_ProvDebugLog && ( ProvDebugLog :: s_ProvDebugLog->GetLogging () ) && ( ( ProvDebugLog :: s_ProvDebugLog->GetLevel () ) & 128 ) ) \
  123. { \
  124. {a ; } \
  125. } \
  126. }
  127. #define DebugMacro8(a) { \
  128. \
  129. if ( ProvDebugLog :: s_ProvDebugLog && ( ProvDebugLog :: s_ProvDebugLog->GetLogging () ) && ( ( ProvDebugLog :: s_ProvDebugLog->GetLevel () ) & 256 ) ) \
  130. { \
  131. {a ; } \
  132. } \
  133. }
  134. #define DebugMacro9(a) { \
  135. \
  136. if ( ProvDebugLog :: s_ProvDebugLog && ( ProvDebugLog :: s_ProvDebugLog->GetLogging () ) && ( ( ProvDebugLog :: s_ProvDebugLog->GetLevel () ) & 512 ) ) \
  137. { \
  138. {a ; } \
  139. } \
  140. }
  141. #define DebugMacro10(a) { \
  142. \
  143. if ( ProvDebugLog :: s_ProvDebugLog && ( ProvDebugLog :: s_ProvDebugLog->GetLogging () ) && ( ( ProvDebugLog :: s_ProvDebugLog->GetLevel () ) & 1024 ) ) \
  144. { \
  145. {a ; } \
  146. } \
  147. }
  148. #define DebugMacro11(a) { \
  149. \
  150. if ( ProvDebugLog :: s_ProvDebugLog && ( ProvDebugLog :: s_ProvDebugLog->GetLogging () ) && ( ( ProvDebugLog :: s_ProvDebugLog->GetLevel () ) & 2048 ) ) \
  151. { \
  152. {a ; } \
  153. } \
  154. }
  155. #define DebugMacro12(a) { \
  156. \
  157. if ( ProvDebugLog :: s_ProvDebugLog && ( ProvDebugLog :: s_ProvDebugLog->GetLogging () ) && ( ( ProvDebugLog :: s_ProvDebugLog->GetLevel () ) & 4096 ) ) \
  158. { \
  159. {a ; } \
  160. } \
  161. }
  162. #define DebugMacro13(a) { \
  163. \
  164. if ( ProvDebugLog :: s_ProvDebugLog && ( ProvDebugLog :: s_ProvDebugLog->GetLogging () ) && ( ( ProvDebugLog :: s_ProvDebugLog->GetLevel () ) & 8192 ) ) \
  165. { \
  166. {a ; } \
  167. } \
  168. }
  169. #define DebugMacro14(a) { \
  170. \
  171. if ( ProvDebugLog :: s_ProvDebugLog && ( ProvDebugLog :: s_ProvDebugLog->GetLogging () ) && ( ( ProvDebugLog :: s_ProvDebugLog->GetLevel () ) & 16384 ) ) \
  172. { \
  173. {a ; } \
  174. } \
  175. }
  176. #define DebugMacro15(a) { \
  177. \
  178. if ( ProvDebugLog :: s_ProvDebugLog && ( ProvDebugLog :: s_ProvDebugLog->GetLogging () ) && ( ( ProvDebugLog :: s_ProvDebugLog->GetLevel () ) & 32768 ) ) \
  179. { \
  180. {a ; } \
  181. } \
  182. }
  183. #endif __PROVLOG_H