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.

96 lines
1.8 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. buf[8095] = 0;
  46. _vsntprintf(
  47. buf + lstrlen(buf),
  48. sizeof(buf)/sizeof(buf[0]) - lstrlen(buf),
  49. format,
  50. *vaList
  51. );
  52. OutputDebugString(buf);
  53. if(hConsole != NULL)
  54. {
  55. WriteConsole(
  56. hConsole,
  57. buf,
  58. _tcslen(buf),
  59. &dump,
  60. NULL
  61. );
  62. }
  63. }
  64. catch(...) {
  65. }
  66. // CS.UnLock();
  67. return;
  68. }
  69. void
  70. TLSDebugOutput(
  71. HANDLE hConsole,
  72. LPTSTR format, ...
  73. )
  74. /*++
  75. ++*/
  76. {
  77. va_list marker;
  78. va_start(marker, format);
  79. DebugOutput(hConsole, format, &marker);
  80. va_end(marker);
  81. return;
  82. }