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.

115 lines
2.8 KiB

  1. //
  2. // Error Handling & Tracing
  3. //
  4. #ifndef DEBUG
  5. #define DEBUG_ALERT(x)
  6. #define ALERT(x) alert(x)
  7. #define ERROR_STRING(x, e) x
  8. #else
  9. #define DEBUG_ALERT(x) alert("File: " + __FILE__ + "\nLine: " + __LINE__ + "\n" + x)
  10. #define ALERT(x) DEBUG_ALERT(x)
  11. #define ERROR_STRING(x, er) ("\nFile:\t"+__FILE__+"\nLine:\t"+__LINE__+"\n"+x+"\n"+("string"==typeof(er)?er:"\nDesc:\t" + er.description + "\nNo:\t" + er.number))
  12. #endif
  13. #ifdef DEBUG
  14. #define InitTrace() InitTraceEx( __FILE__ )
  15. #else
  16. #define InitTrace()
  17. #endif
  18. #ifndef DEBUG
  19. #include "debug_decl.inc"
  20. #else
  21. #include "constants.inc"
  22. <Script id="idScriptdebug" name="idScriptdebug" Language="JavaScript">
  23. var g_szFuncName = null;
  24. var TraceFso = null;
  25. var TraceFileHandle = null;
  26. var TraceFile = null;
  27. var TracetFileName = null;
  28. var g_oShell = null;
  29. var g_bDebugSpew = 0;
  30. function InitTraceEx( szFileName )
  31. {
  32. try{
  33. if( null == g_oShell )
  34. {
  35. g_oShell = new ActiveXObject("WScript.Shell");
  36. }
  37. g_bDebugSpew = g_oShell.RegRead( c_szREGDebugSpew );
  38. //alert("g_bDebugSpew: " + g_bDebugSpew);
  39. if( g_bDebugSpew )
  40. {
  41. TraceFso = new ActiveXObject("Scripting.FileSystemObject");
  42. var tFolder = TraceFso.GetSpecialFolder(2); // Get Path to temp directory
  43. TracetFileName = tFolder + "\\" + szFileName + "_RA.log";
  44. TraceFileHandle = TraceFso.OpenTextFile( TracetFileName, 8, -2 );
  45. DebugTrace( "Start of new helpsession:::" );
  46. }
  47. }
  48. catch(x)
  49. {
  50. //alert("Error: " + x.description );
  51. }
  52. }
  53. function EndTrace()
  54. {
  55. DebugTrace( "End of new helpsession:::" );
  56. try
  57. {
  58. if( g_bDebugSpew )
  59. {
  60. TraceFileHandle.Close();
  61. }
  62. }
  63. catch(e)
  64. {
  65. }
  66. }
  67. function DebugTrace( szMsg )
  68. {
  69. if( g_bDebugSpew )
  70. {
  71. if( null == TraceFileHandle )
  72. {
  73. InitTrace();
  74. }
  75. var d = new Date();
  76. try
  77. {
  78. TraceFileHandle.WriteLine( d.toLocaleString() + "::" + szMsg );
  79. }
  80. catch(e)
  81. {
  82. // Dont do any thing.
  83. }
  84. }
  85. }
  86. function TraceFunctEnter( szFuncName )
  87. {
  88. if( g_bDebugSpew )
  89. {
  90. g_szFuncName = szFuncName;
  91. DebugTrace("Entering " + g_szFuncName);
  92. }
  93. }
  94. function TraceFunctLeave()
  95. {
  96. if( g_bDebugSpew )
  97. {
  98. DebugTrace("Leaving " + g_szFuncName);
  99. }
  100. }
  101. </Script>
  102. #endif