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.

88 lines
1.7 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Copyright (c) 1997-1999 Microsoft Corporation
  4. //
  5. // File: debug.cpp
  6. //
  7. // Contents: License Server debugging spew routine
  8. //
  9. // History:
  10. //
  11. //---------------------------------------------------------------------------
  12. #include "pch.cpp"
  13. #include <windows.h>
  14. #include <stdio.h>
  15. #include <tchar.h>
  16. #include "debug.h"
  17. #include "locks.h"
  18. #include "dbgout.h"
  19. //-----------------------------------------------------------
  20. static HANDLE DbgConsole=NULL;
  21. //static LPTSTR DbgEventSrc;
  22. static DWORD DbgSeverityCode=0;
  23. static DWORD DbgLevel=0;
  24. static DWORD DbgModule=0;
  25. //CCriticalSection ConsoleLock;
  26. //-----------------------------------------------------------
  27. void
  28. InitDBGPrintf(
  29. IN BOOL bConsole,
  30. IN LPTSTR DbgEventSrc, // unuse for now
  31. IN DWORD dwDebug
  32. )
  33. /*
  34. */
  35. {
  36. DbgSeverityCode = (dwDebug & DEBUG_SEVERITY) >> 10;
  37. DbgModule = (dwDebug & DEBUG_MODULE) >> 12;
  38. DbgLevel = dwDebug & DEBUG_LEVEL;
  39. if(DbgConsole == NULL && bConsole == TRUE)
  40. {
  41. // allocate a console, ignore error
  42. AllocConsole();
  43. DbgConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  44. }
  45. return;
  46. }
  47. //-----------------------------------------------------------
  48. void
  49. DBGPrintf(
  50. DWORD dwSeverityCode,
  51. DWORD dwModule,
  52. DWORD dwLevel,
  53. LPTSTR format, ...
  54. )
  55. /*
  56. */
  57. {
  58. if((dwModule & DbgModule) == 0)
  59. return;
  60. //
  61. // Report all error
  62. //
  63. if((dwSeverityCode & DbgSeverityCode) == 0)
  64. return;
  65. if((dwLevel & DbgLevel) == 0)
  66. return;
  67. va_list marker;
  68. va_start(marker, format);
  69. DebugOutput(DbgConsole, format, &marker);
  70. va_end(marker);
  71. return;
  72. }