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.

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