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.

367 lines
18 KiB

  1. /*---------------------------------------------------------------------------*\
  2. | NTLOG OBJECT
  3. | This module defines the NTLOG object. This header must be include in all
  4. | modules which make NTLOG calls, or utilizes the definitions.
  5. |
  6. |
  7. | Copyright (C) 1990-2001 Microsoft Corp.
  8. |
  9. \*---------------------------------------------------------------------------*/
  10. #ifndef _NTLOG_
  11. #define _NTLOG_
  12. // If doing C++ stuff, this needs to be here to
  13. // prevent decorating of symbols.
  14. //
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. // **NEW** 10/26/96 Log path environment variable **NEW**
  19. // if the environment variable _NTLOG_LOGPATH is set to a non-empty string
  20. // the value of this variable will be prepended to the log name
  21. // The path should NOT include a trailing backslash.
  22. // No validation is performed on the path, however, if the value is invalid,
  23. // the call to tlCreateLog will fail because CreateFile will fail.
  24. // Basically should be used to force logfiles to a location other than the current directory
  25. // without changing the source file.
  26. // **NEW** 1/20/97 environment variable to force diffable files **NEW**
  27. // if the environment variable _NTLOG_DIFFABLE is set, then log files
  28. // will not contain process and thread specific data, and time and date data.
  29. //
  30. // NTLOG STYLES
  31. // The folowing are logging levels in which the Log Object can prejudice
  32. // itself. These are used by the tlLogCreate() in initializing the
  33. // Log Object information. A combination of characteristics is obtained
  34. // by bitwise OR'ing these identifiers together.
  35. //
  36. #define LOG_LEVELS 0x0000FFFFL // These are used to mask out the
  37. #define LOG_STYLES 0xFFFF0000L // styles or levels from log object.
  38. #define TLS_LOGALL 0x0000FFFFL // Log output. Logs all the time.
  39. #define TLS_LOG 0x00000000L // Log output. Logs all the time.
  40. #define TLS_INFO 0x00002000L // Log information.
  41. #define TLS_ABORT 0x00000001L // Log Abort, then kill process.
  42. #define TLS_SEV1 0x00000002L // Log at Severity 1 level
  43. #define TLS_SEV2 0x00000004L // Log at Severity 2 level
  44. #define TLS_SEV3 0x00000008L // Log at Severity 3 level
  45. #define TLS_WARN 0x00000010L // Log at Warn level
  46. #define TLS_PASS 0x00000020L // Log at Pass level
  47. #define TLS_BLOCK 0x00000400L // Block the variation.
  48. #define TLS_BREAK 0x00000800L // Debugger break;
  49. #define TLS_CALLTREE 0x00000040L // Log call-tree (function tracking).
  50. #define TLS_SYSTEM 0x00000080L // Log System debug.
  51. #define TLS_TESTDEBUG 0x00001000L // Debug level.
  52. #define TLS_TEST 0x00000100L // Log Test information (user).
  53. #define TLS_VARIATION 0x00000200L // Log testcase level.
  54. #define TLS_REFRESH 0x00010000L // Create new file || trunc to zero.
  55. #define TLS_SORT 0x00020000L // Sort file output by instance.
  56. #define TLS_DEBUG 0x00040000L // Output to debug (com) monitor).
  57. #define TLS_MONITOR 0x00080000L // Output to 2nd screen.
  58. #define TLS_VIDCOLOR 0x00100000L // Use different colors for display output
  59. #define TLS_PROLOG 0x00200000L // Prolog line information.
  60. #define TLS_WINDOW 0x00400000L // Log to windows.
  61. #define TLS_ACCESSON 0x00800000L // Keep log-file open.
  62. #define TLS_DIFFABLE 0x01000000L // make log file windiff'able (no dates..)
  63. #define TLS_NOHEADER 0x02000000L // suppress headers so it is more diffable
  64. #define TLS_TIMESTAMP 0x04000000L // To print the timestamps
  65. #define TLS_VIDEOLOG 0x08000000L // convert ?.log to ?.bpp.log (color depth)
  66. #define TLS_HTML 0x10000000L // write log file as an html.
  67. // NTLOG tlLogOut() PARAMETERS
  68. // The following defines are used in the tlLogOut() function to output the
  69. // filename and line numbers associated with the caller. This uses the
  70. // preprocessors capabilities for obtaining the file/line.
  71. //
  72. #define TL_LOG TLS_LOG ,TEXT(__FILE__),(int)__LINE__
  73. #define TL_ABORT TLS_ABORT ,TEXT(__FILE__),(int)__LINE__
  74. #define TL_SEV1 TLS_SEV1 ,TEXT(__FILE__),(int)__LINE__
  75. #define TL_SEV2 TLS_SEV2 ,TEXT(__FILE__),(int)__LINE__
  76. #define TL_SEV3 TLS_SEV3 ,TEXT(__FILE__),(int)__LINE__
  77. #define TL_WARN TLS_WARN ,TEXT(__FILE__),(int)__LINE__
  78. #define TL_PASS TLS_PASS ,TEXT(__FILE__),(int)__LINE__
  79. #define TL_BLOCK TLS_BLOCK ,TEXT(__FILE__),(int)__LINE__
  80. #define TL_INFO TLS_INFO ,TEXT(__FILE__),(int)__LINE__
  81. #define TL_BREAK TLS_BREAK ,TEXT(__FILE__),(int)__LINE__
  82. #define TL_CALLTREE TLS_CALLTREE ,TEXT(__FILE__),(int)__LINE__
  83. #define TL_SYSTEM TLS_SYSTEM ,TEXT(__FILE__),(int)__LINE__
  84. #define TL_TESTDEBUG TLS_TESTDEBUG,TEXT(__FILE__),(int)__LINE__
  85. #define TL_TEST TLS_TEST ,TEXT(__FILE__),(int)__LINE__
  86. #define TL_VARIATION TLS_VARIATION,TEXT(__FILE__),(int)__LINE__
  87. // Struct used by tlGet/SetVar/TestStats
  88. //
  89. typedef struct _NTLOGSTATS {
  90. int nAbort;
  91. int nBlock;
  92. int nSev1;
  93. int nSev2;
  94. int nSev3;
  95. int nWarn;
  96. int nPass;
  97. }
  98. NTLOGSTATS, *LPNTLOGSTATS;
  99. // Use enumerated indexes to access palette.
  100. // Colors are defined in wincon.h
  101. typedef struct _VIDEOPALETTE {
  102. WORD wINDEX_DEFAULT;
  103. WORD wINDEX_INFO;
  104. WORD wINDEX_SEV1;
  105. WORD wINDEX_SEV2;
  106. WORD wINDEX_SEV3;
  107. WORD wINDEX_BLOCK;
  108. WORD wINDEX_ABORT;
  109. WORD wINDEX_WARN;
  110. WORD wINDEX_PASS;
  111. }
  112. VIDEOPALETTE, *LPVIDEOPALETTE;
  113. // NTLOG API (EXPORT METHODS)
  114. // These routines are exported from the library. These should be the only
  115. // interface with the NTLOG object.
  116. //
  117. HANDLE APIENTRY tlCreateLog_W(LPCWSTR,DWORD);
  118. HANDLE APIENTRY tlCreateLog_A(LPCSTR,DWORD);
  119. HANDLE APIENTRY tlCreateLogEx_W(LPCWSTR,DWORD,LPSECURITY_ATTRIBUTES);
  120. HANDLE APIENTRY tlCreateLogEx_A(LPCSTR,DWORD,LPSECURITY_ATTRIBUTES);
  121. BOOL APIENTRY tlDestroyLog(HANDLE);
  122. BOOL APIENTRY tlAddParticipant(HANDLE,DWORD,int);
  123. BOOL APIENTRY tlRemoveParticipant(HANDLE);
  124. DWORD APIENTRY tlParseCmdLine_W(LPCWSTR);
  125. DWORD APIENTRY tlParseCmdLine_A(LPCSTR);
  126. int APIENTRY tlGetLogFileName_W(HANDLE,LPWSTR);
  127. int APIENTRY tlGetLogFileName_A(HANDLE,LPSTR);
  128. BOOL APIENTRY tlSetLogFileName_W(HANDLE,LPCWSTR);
  129. BOOL APIENTRY tlSetLogFileName_A(HANDLE,LPCSTR);
  130. DWORD APIENTRY tlGetLogInfo(HANDLE);
  131. DWORD APIENTRY tlSetLogInfo(HANDLE,DWORD);
  132. HANDLE APIENTRY tlPromptLog(HWND,HANDLE);
  133. int APIENTRY tlGetTestStat(HANDLE,DWORD);
  134. int APIENTRY tlGetVariationStat(HANDLE,DWORD);
  135. VOID APIENTRY tlClearTestStats(HANDLE);
  136. VOID APIENTRY tlClearVariationStats(HANDLE);
  137. VOID APIENTRY tlSetTestStats(HANDLE,LPNTLOGSTATS);
  138. VOID APIENTRY tlSetVariationStats(HANDLE,LPNTLOGSTATS);
  139. BOOL APIENTRY tlStartVariation(HANDLE);
  140. DWORD APIENTRY tlEndVariation(HANDLE);
  141. VOID APIENTRY tlReportStats(HANDLE);
  142. BOOL APIENTRY tlLogX_W(HANDLE,DWORD,LPCWSTR,int,LPCWSTR);
  143. BOOL APIENTRY tlLogX_A(HANDLE,DWORD,LPCSTR,int,LPCSTR);
  144. BOOL FAR __cdecl tlLog_W(HANDLE,DWORD,LPCWSTR,int,LPCWSTR,...);
  145. BOOL FAR __cdecl tlLog_A(HANDLE,DWORD,LPCSTR,int,LPCSTR,...);
  146. BOOL APIENTRY tlGetVideoPalette(HANDLE,LPVIDEOPALETTE);
  147. BOOL APIENTRY tlSetVideoPalette(HANDLE,LPVIDEOPALETTE);
  148. BOOL APIENTRY tlResetVideoPalette(HANDLE);
  149. VOID APIENTRY tlAdjustFileName_W(HANDLE,LPWSTR,UINT);
  150. VOID APIENTRY tlAdjustFileName_A(HANDLE,LPSTR,UINT);
  151. BOOL APIENTRY tlIsTerminalServerSession();
  152. BOOL APIENTRY tlFlushLogFileBuffer(HANDLE);
  153. // HCT Assertion API
  154. BOOL APIENTRY tlhct_StartAssertion_W(HANDLE,LPCWSTR,int,LPCWSTR,LPCWSTR,LPCWSTR);
  155. BOOL APIENTRY tlhct_StartAssertion_A(HANDLE,LPCSTR,int,LPCSTR,LPCSTR,LPCSTR);
  156. BOOL APIENTRY tlhct_InfoAssertion_W(HANDLE,LPCWSTR,int,LPCWSTR,DWORD,LPCWSTR);
  157. BOOL APIENTRY tlhct_InfoAssertion_A(HANDLE,LPCSTR,int,LPCSTR,DWORD,LPCSTR);
  158. BOOL APIENTRY tlhct_EndAssertion_W(HANDLE,LPCWSTR,int,LPCWSTR,LPCWSTR);
  159. BOOL APIENTRY tlhct_EndAssertion_A(HANDLE,LPCSTR,int,LPCSTR,LPCSTR);
  160. BOOL APIENTRY tlhct_LogToolInfo_W(HANDLE,LPCWSTR,int,LPCWSTR,LPCWSTR);
  161. BOOL APIENTRY tlhct_LogToolInfo_A(HANDLE,LPCSTR,int,LPCSTR,LPCSTR);
  162. #ifdef UNICODE
  163. #define tlCreateLog tlCreateLog_W
  164. #define tlCreateLogEx tlCreateLogEx_W
  165. #define tlParseCmdLine tlParseCmdLine_W
  166. #define tlGetLogFileName tlGetLogFileName_W
  167. #define tlSetLogFileName tlSetLogFileName_W
  168. #define tlLogX tlLogX_W
  169. #define tlLog tlLog_W
  170. #define tlAdjustFileName tlAdjustFileName_W
  171. #define tlhct_StartAssertion(hLog, Assert, Title, Desc) tlhct_StartAssertion_W(hLog, TEXT(__FILE__), __LINE__, Assert, Title, Desc)
  172. #define tlhct_InfoAssertion(hLog, Assert, Title, Desc) tlhct_InfoAssertion_W(hLog, TEXT(__FILE__), __LINE__, Assert, Title, Desc)
  173. #define tlhct_EndAssertion(hLog, Assert, Result) tlhct_EndAssertion_W(hLog, TEXT(__FILE__), __LINE__, Assert, Result)
  174. #define tlhct_LogToolInfo(hLog, Test, Version) tlhct_LogToolInfo_W(hLog, TEXT(__FILE__), __LINE__, Test, Version)
  175. #else
  176. #define tlCreateLog tlCreateLog_A
  177. #define tlCreateLogEx tlCreateLogEx_A
  178. #define tlParseCmdLine tlParseCmdLine_A
  179. #define tlGetLogFileName tlGetLogFileName_A
  180. #define tlSetLogFileName tlSetLogFileName_A
  181. #define tlLogX tlLogX_A
  182. #define tlLog tlLog_A
  183. #define tlAdjustFileName tlAdjustFileName_A
  184. #define tlhct_StartAssertion(hLog, Assert, Title, Desc) tlhct_StartAssertion_A(hLog, __FILE__, __LINE__, Assert, Title, Desc)
  185. #define tlhct_InfoAssertion(hLog, Assert, Title, Desc) tlhct_InfoAssertion_A(hLog, __FILE__, __LINE__, Assert, Title, Desc)
  186. #define tlhct_EndAssertion(hLog, Assert, Result) tlhct_EndAssertion_A(hLog, __FILE__, __LINE__, Assert, Result)
  187. #define tlhct_LogToolInfo(hLog, Test, Version) tlhct_LogToolInfo_A(hLog, __FILE__, __LINE__, Test, Version)
  188. #endif
  189. // HCT Assertion ResultCodes
  190. /* dwResultCode values for calls to hct_InfoAssertion() */
  191. #define HCT_PASS 0
  192. #define HCT_FAIL 1
  193. #define HCT_WARN 2
  194. #define HCT_INFO 3
  195. // RATS MACROS
  196. // These macros are provided as a common logging interface which is
  197. // compatible with the RATS logging-macros.
  198. //
  199. #define TESTDATA HANDLE hLog;
  200. #define TESTOTHERDATA extern HANDLE hLog;
  201. // These must be useless. TL_* macros do not include TLS_TEST or
  202. // TLS_VARIATION, so they DO NOT count in the stats. Leaving them around
  203. // for 'backwards compatibility, if anyone was actually using them...
  204. //
  205. #define L_PASS hLog,TL_PASS
  206. #define L_WARN hLog,TL_WARN
  207. #define L_DEBUG hLog,TL_TESTDEBUG
  208. #define L_TRACE hLog,TL_SYSTEM
  209. #define L_FAIL hLog,TL_SEV1
  210. #define L_FAIL2 hLog,TL_SEV2
  211. #define L_FAIL3 hLog,TL_SEV3
  212. #define L_BLOCK hLog,TL_BLOCK
  213. // macros for incrementing test/variation counts for various log levels
  214. //
  215. #define L_TESTPASS hLog,TLS_TEST | TL_PASS
  216. #define L_TESTWARN hLog,TLS_TEST | TL_WARN
  217. #define L_TESTDEBUG hLog,TLS_TEST | TL_TESTDEBUG
  218. #define L_TESTTRACE hLog,TLS_TEST | TL_SYSTEM
  219. #define L_TESTFAIL hLog,TLS_TEST | TL_SEV1
  220. #define L_TESTFAIL2 hLog,TLS_TEST | TL_SEV2
  221. #define L_TESTFAIL3 hLog,TLS_TEST | TL_SEV3
  222. #define L_TESTBLOCK hLog,TLS_TEST | TL_BLOCK
  223. #define L_TESTABORT hLog,TLS_TEST | TL_ABORT
  224. #define L_VARPASS hLog,TLS_VARIATION | TL_PASS
  225. #define L_VARWARN hLog,TLS_VARIATION | TL_WARN
  226. #define L_VARDEBUG hLog,TLS_VARIATION | TL_TESTDEBUG
  227. #define L_VARTRACE hLog,TLS_VARIATION | TL_SYSTEM
  228. #define L_VARFAIL hLog,TLS_VARIATION | TL_SEV1
  229. #define L_VARFAIL2 hLog,TLS_VARIATION | TL_SEV2
  230. #define L_VARFAIL3 hLog,TLS_VARIATION | TL_SEV3
  231. #define L_VARBLOCK hLog,TLS_VARIATION | TL_BLOCK
  232. #define L_VARABORT hLog,TLS_VARIATION | TL_ABORT
  233. #define TESTBEGIN(cmd,logfilename){ \
  234. DWORD __tlFlags; \
  235. __tlFlags = tlParseCmdLine(cmd); \
  236. hLog = tlCreateLog(logfilename,__tlFlags); \
  237. tlAddParticipant(hLog,0l,0);
  238. #define TESTEND tlRemoveParticipant(hLog); \
  239. tlDestroyLog(hLog); \
  240. }
  241. #define VARIATION(name,flags) if(tlStartVariation(hLog)) \
  242. { \
  243. DWORD __dwResult; \
  244. tlLog(hLog,TL_VARIATION,TEXT("%s"),(LPTSTR)name);
  245. #define ENDVARIATION __dwResult = tlEndVariation(hLog); \
  246. tlLog(hLog,__dwResult | TL_VARIATION,TEXT("End Variation reported")); \
  247. }
  248. #define ENTERTHREAD(_hLG,_szNM) { \
  249. LPTSTR _lpFN = _szNM; \
  250. tlAddParticipant(_hLG,0,0); \
  251. tlLog(_hLG,TL_CALLTREE,TEXT("Entering %s()"),(LPTSTR)_lpFN);
  252. #define LEAVETHREAD(_hLG,_ret) \
  253. tlLog(_hLG,TL_CALLTREE,TEXT("Exiting %s()"),(LPTSTR)_lpFN); \
  254. tlRemoveParticipant(_hLG); \
  255. return(_ret); \
  256. }
  257. #define LEAVETHREADVOID(_hLG) \
  258. tlLog(_hLG,TL_CALLTREE,TEXT("Exiting %s()"),(LPTSTR)_lpFN); \
  259. tlRemoveParticipant(_hLG); \
  260. return; \
  261. }
  262. // Macro to report variation PASS/FAIL statistic (based on an expression)
  263. //
  264. #define THPRINTF tlLog
  265. #define TESTRESULT(expr,msg) (expr) ? tlLog(L_TESTPASS,TEXT("%s"),(LPTSTR)msg) : tlLog(L_TESTFAIL2,TEXT("%s"),(LPTSTR)msg)
  266. #define TESTFAIL(msg) TESTSEV2(msg)
  267. #define TESTSEV1(msg) tlLog(L_TESTFAIL ,TEXT("%s"),(LPTSTR)msg);
  268. #define TESTSEV2(msg) tlLog(L_TESTFAIL2,TEXT("%s"),(LPTSTR)msg);
  269. #define TESTSEV3(msg) tlLog(L_TESTFAIL3,TEXT("%s"),(LPTSTR)msg);
  270. #define TESTPASS(msg) tlLog(L_TESTPASS ,TEXT("%s"),(LPTSTR)msg);
  271. #define TESTABORT(msg) tlLog(L_TESTABORT,TEXT("%s"),(LPTSTR)msg);
  272. #define TESTWARN(expr,msg) if(expr) tlLog(L_TESTWARN,TEXT("%s"),(LPTSTR)msg);
  273. #define TESTBLOCK(expr,msg) if(expr) tlLog(L_TESTBLOCK,TEXT("%s"),(LPTSTR)msg);
  274. #define VARRESULT(expr,msg) (expr) ? tlLog(L_VARPASS,TEXT("%s"),(LPTSTR)msg) : tlLog(L_VARFAIL2,TEXT("%s"),(LPTSTR)msg)
  275. #define VARFAIL(msg) VARSEV2(msg)
  276. #define VARSEV1(msg) tlLog(L_VARFAIL ,TEXT("%s"),(LPTSTR)msg);
  277. #define VARSEV2(msg) tlLog(L_VARFAIL2,TEXT("%s"),(LPTSTR)msg);
  278. #define VARSEV3(msg) tlLog(L_VARFAIL3,TEXT("%s"),(LPTSTR)msg);
  279. #define VARPASS(msg) tlLog(L_VARPASS ,TEXT("%s"),(LPTSTR)msg);
  280. #define VARABORT(msg) tlLog(L_VARABORT,TEXT("%s"),(LPTSTR)msg);
  281. #define VARWARN(expr,msg) if(expr) tlLog(L_VARWARN,TEXT("%s"),(LPTSTR)msg);
  282. #define VARBLOCK(expr,msg) if(expr) tlLog(L_VARBLOCK,TEXT("%s"),(LPTSTR)msg);
  283. #define VAR_SI 0x01 // Ship Issue
  284. #define VAR_NSI 0x02 // Non-ship Issue
  285. #define VAR_LI 0x03 // Less Important
  286. #define VAR_ISSUE_MASK 0x03 // To get ship-issue bits only
  287. #define VAR_TIMEABLE 0x04 // Var. used in timing suites
  288. #define CORE_API 0x08 // API is in most used list
  289. #define CORE_SI (CORE_API | VAR_TIMEABLE | VAR_SI ) //
  290. #define CORE_NSI (CORE_API | VAR_TIMEABLE | VAR_NSI) //
  291. #define NONCORE_SI (VAR_TIMEABLE | VAR_SI ) //
  292. #define NONCORE_NSI (VAR_TIMEABLE | VAR_NSI) //
  293. // CALLTREE Macros
  294. // These macros are useful for bracketing function-calls.
  295. //
  296. #define ENTER(_hLG,_szNM) { \
  297. LPTSTR _lpFN = _szNM; \
  298. tlLog(_hLG,TL_CALLTREE,TEXT("Entering %s()"),(LPTSTR)_lpFN);
  299. #define LEAVE(_hLG,_ret) \
  300. tlLog(_hLG,TL_CALLTREE,TEXT("Exiting %s()"),(LPTSTR)_lpFN); \
  301. return(_ret); \
  302. }
  303. #define LEAVEVOID(_hLG) \
  304. tlLog(_hLG,TL_CALLTREE,TEXT("Exiting %s()"),(LPTSTR)_lpFN); \
  305. return; \
  306. }
  307. #ifdef __cplusplus
  308. }
  309. #endif
  310. #define LPSZ_KEY_EMPTY TEXT("None")
  311. #define LPSZ_TERM_SERVER TEXT("Terminal Server")
  312. #endif // _NTLOG_