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.

203 lines
3.9 KiB

  1. #define __LOG_C__
  2. /*****************************************************************************
  3. /* Log include files
  4. /*****************************************************************************/
  5. #include <windows.h>
  6. #include <stdlib.h>
  7. #include <wtypes.h>
  8. #include <limits.h>
  9. #include "log.h"
  10. #include "hidsdi.h"
  11. #define USE_MACROS
  12. #include "list.h"
  13. #include "hidtest.h"
  14. #include "debug.h"
  15. /*****************************************************************************
  16. /* Local macro definitions
  17. /*****************************************************************************/
  18. #define IS_LOGGING_ON ((NULL != hTestLog) && (IsLogOn))
  19. /*****************************************************************************
  20. /* Module global variable declarations for logging
  21. /*****************************************************************************/
  22. static HANDLE hTestLog = NULL;
  23. static BOOL IsLogOn = FALSE;
  24. static CHAR String[1024];
  25. /*****************************************************************************
  26. /* Exportable logging function definitions
  27. /*****************************************************************************/
  28. BOOL
  29. HIDTest_CreateTestLogA(
  30. IN PCHAR LogName
  31. )
  32. {
  33. hTestLog = tlCreateLog(LogName, TLS_REFRESH | TLS_LOGALL);
  34. if (NULL != hTestLog) {
  35. tlAddParticipant(hTestLog, 0, 1);
  36. }
  37. IsLogOn = (NULL != hTestLog);
  38. return (IsLogOn);
  39. }
  40. VOID
  41. HIDTest_CloseTestLogA(
  42. VOID
  43. )
  44. {
  45. if (NULL != hTestLog) {
  46. tlRemoveParticipant(hTestLog);
  47. tlDestroyLog(hTestLog);
  48. }
  49. return;
  50. }
  51. VOID
  52. HIDTest_SetLogOnA(
  53. BOOL TurnOn
  54. )
  55. {
  56. IsLogOn = TurnOn;
  57. return;
  58. }
  59. /*****************************************************************************
  60. /* Local functions to deal with NT based logging
  61. /****************************************************************************/
  62. VOID
  63. HIDTest_LogStartTest(
  64. PCHAR TestName
  65. )
  66. {
  67. if (IS_LOGGING_ON) {
  68. tlLog(hTestLog, TL_INFO, TestName);
  69. tlClearTestStats(hTestLog);
  70. }
  71. return;
  72. }
  73. VOID
  74. HIDTest_LogStartTestIteration(
  75. ULONG IterationNumber
  76. )
  77. {
  78. if (IS_LOGGING_ON) {
  79. wsprintf(String, "Iteration number: %u", IterationNumber);
  80. tlLog(hTestLog, TL_INFO, String);
  81. }
  82. return;
  83. }
  84. VOID
  85. HIDTest_LogStartVariationWithDeviceHandle(
  86. HANDLE DeviceHandle,
  87. BOOL IsLegal,
  88. PCHAR Description
  89. )
  90. {
  91. wsprintf(String,
  92. "DeviceHandle = %u, IsLegalDeviceHandle = %s, Test Desc: %s",
  93. (DeviceHandle),
  94. (IsLegal) ? "TRUE" : "FALSE",
  95. Description
  96. );
  97. LOG_INTERMEDIATE_VARIATION_RESULT(String);
  98. return;
  99. }
  100. VOID
  101. HIDTest_LogStartVariation(
  102. PCHAR Variation
  103. )
  104. {
  105. if (IS_LOGGING_ON) {
  106. tlStartVariation(hTestLog);
  107. tlLog(hTestLog, TL_INFO, Variation);
  108. }
  109. return;
  110. }
  111. VOID
  112. HIDTest_LogVariationResult(
  113. INT Level,
  114. PCHAR VarString
  115. )
  116. {
  117. if (IS_LOGGING_ON) {
  118. tlLog(hTestLog, Level | TL_VARIATION, VarString);
  119. }
  120. return;
  121. }
  122. VOID
  123. HIDTest_LogEndVariation(
  124. VOID
  125. )
  126. {
  127. DWORD dwVariationResult;
  128. if (IS_LOGGING_ON) {
  129. dwVariationResult = tlEndVariation(hTestLog);
  130. tlLog(hTestLog, dwVariationResult | TL_VARIATION, "End variation");
  131. }
  132. return;
  133. }
  134. VOID
  135. HIDTest_LogEndTest(
  136. VOID
  137. )
  138. {
  139. if (IS_LOGGING_ON) {
  140. tlLog(hTestLog, TL_TEST, "");
  141. }
  142. return;
  143. }
  144. VOID
  145. HIDTest_LogIntermediateVariationResult(
  146. IN PCHAR VarResult
  147. )
  148. {
  149. if (IS_LOGGING_ON) {
  150. tlLog(hTestLog, TL_INFO, VarResult);
  151. }
  152. return;
  153. }
  154. VOID
  155. HIDTest_LogTestWarning(
  156. IN PCHAR WarningMsg
  157. )
  158. {
  159. if (IS_LOGGING_ON) {
  160. tlLog(hTestLog, TL_WARN, WarningMsg);
  161. }
  162. return;
  163. }
  164. VOID
  165. HIDTest_LogTestError(
  166. IN PCHAR ErrMsg
  167. )
  168. {
  169. if (IS_LOGGING_ON) {
  170. wsprintf(String,
  171. "Critical test error: %s, cannot proceed",
  172. ErrMsg
  173. );
  174. tlLog(hTestLog, TL_SEV1, String);
  175. }
  176. return;
  177. }