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.

95 lines
1.7 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Copyright (c) 1997-1999 Microsoft Corporation
  4. //
  5. // File:
  6. //
  7. // Contents:
  8. //
  9. // History:
  10. //
  11. //---------------------------------------------------------------------------
  12. #include <windows.h>
  13. #include <stdio.h>
  14. #include "dbgout.h"
  15. #include "locks.h"
  16. //CCriticalSection CS;
  17. void
  18. DebugOutput(
  19. HANDLE hConsole,
  20. LPTSTR format,
  21. va_list* vaList
  22. )
  23. /*++
  24. ++*/
  25. {
  26. TCHAR buf[8096];
  27. DWORD dump;
  28. SYSTEMTIME sysTime;
  29. GetSystemTime(&sysTime);
  30. // CS.Lock();
  31. try {
  32. memset(buf, 0, sizeof(buf));
  33. _sntprintf(
  34. buf,
  35. sizeof(buf)/sizeof(buf[0]),
  36. _TEXT(" %d [%d:%d:%d:%d:%d.%d] : "),
  37. GetCurrentThreadId(),
  38. sysTime.wMonth,
  39. sysTime.wDay,
  40. sysTime.wHour,
  41. sysTime.wMinute,
  42. sysTime.wSecond,
  43. sysTime.wMilliseconds
  44. );
  45. _vsntprintf(
  46. buf + lstrlen(buf),
  47. sizeof(buf)/sizeof(buf[0]) - lstrlen(buf),
  48. format,
  49. *vaList
  50. );
  51. OutputDebugString(buf);
  52. if(hConsole != NULL)
  53. {
  54. WriteConsole(
  55. hConsole,
  56. buf,
  57. _tcslen(buf),
  58. &dump,
  59. NULL
  60. );
  61. }
  62. }
  63. catch(...) {
  64. }
  65. // CS.UnLock();
  66. return;
  67. }
  68. void
  69. TLSDebugOutput(
  70. HANDLE hConsole,
  71. LPTSTR format, ...
  72. )
  73. /*++
  74. ++*/
  75. {
  76. va_list marker;
  77. va_start(marker, format);
  78. DebugOutput(hConsole, format, &marker);
  79. va_end(marker);
  80. return;
  81. }