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.

105 lines
2.3 KiB

  1. //+------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1993.
  5. //
  6. // File: bmlog.cxx
  7. //
  8. // Contents: Benchmark test error logging
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 29-July-93 t-martig Created
  15. //
  16. //--------------------------------------------------------------------------
  17. #include <benchmrk.hxx>
  18. #include <bmoutput.hxx>
  19. #include <bmlog.hxx>
  20. CTestOutput *logOutput;
  21. //+------------------------------------------------------------------------
  22. //
  23. // funtion: LogTo
  24. //
  25. // purpose: writes the benchmark header to the logfile
  26. //
  27. //+------------------------------------------------------------------------
  28. void LogTo (CTestOutput *_logOutput)
  29. {
  30. logOutput = _logOutput;
  31. _SYSTEMTIME stTimeDate;
  32. logOutput->WriteString (TEXT("CairOLE Benchmark Log File\t"));
  33. GetLocalTime (&stTimeDate);
  34. logOutput->WriteDate (&stTimeDate);
  35. logOutput->WriteString (TEXT("\t"));
  36. logOutput->WriteTime (&stTimeDate);
  37. logOutput->WriteString (TEXT("\n\n"));
  38. }
  39. //+------------------------------------------------------------------------
  40. //
  41. // funtion: LogSection
  42. //
  43. // purpose: writes the section header to the logfile
  44. //
  45. //+------------------------------------------------------------------------
  46. void LogSection (LPTSTR lpszName)
  47. {
  48. if (!logOutput)
  49. return;
  50. logOutput->WriteString (lpszName);
  51. logOutput->WriteString (TEXT("\n"));
  52. }
  53. //+------------------------------------------------------------------------
  54. //
  55. // funtion: Log
  56. //
  57. // purpose: records the result of one action taken by the benchmark test
  58. //
  59. //+------------------------------------------------------------------------
  60. int Log (LPTSTR lpszActionName, SCODE hr)
  61. {
  62. if (!logOutput)
  63. return !SUCCEEDED(hr);
  64. logOutput->WriteString (TEXT(" "));
  65. logOutput->WriteString (lpszActionName);
  66. if (SUCCEEDED(hr))
  67. {
  68. logOutput->WriteString (TEXT("\tOK\n"));
  69. return FALSE;
  70. }
  71. else
  72. {
  73. logOutput->WriteString (TEXT("\tERROR: "));
  74. logOutput->WriteSCODE (hr);
  75. logOutput->WriteString (TEXT("\n"));
  76. return TRUE;
  77. }
  78. }
  79. int Log (LPTSTR lpszActionName, ULONG ulCode)
  80. {
  81. if (!logOutput)
  82. return FALSE;
  83. logOutput->WriteString (TEXT(" "));
  84. logOutput->WriteString (lpszActionName);
  85. logOutput->WriteLong(ulCode);
  86. return TRUE;
  87. }