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.

201 lines
6.2 KiB

  1. @if "%_echo%"=="" echo off
  2. @rem
  3. @rem Manage MSMQ Release Bits Tracing
  4. @rem
  5. @rem Author: Shai Kariv (shaik) 05-Apr-2001
  6. @rem
  7. echo mqtrace 1.1 - Manage MSMQ Release Bits Tracing.
  8. @rem
  9. @rem Jump to where we handle usage
  10. @rem
  11. if /I "%1" == "help" goto Usage
  12. if /I "%1" == "-help" goto Usage
  13. if /I "%1" == "/help" goto Usage
  14. if /I "%1" == "-h" goto Usage
  15. if /I "%1" == "/h" goto Usage
  16. if /I "%1" == "-?" goto Usage
  17. if /I "%1" == "/?" goto Usage
  18. @rem
  19. @rem Set TraceFormat environment variable
  20. @rem
  21. if /I "%1" == "-path" shift&goto SetPath
  22. if /I "%1" == "/path" shift&goto SetPath
  23. goto EndSetPath
  24. :SetPath
  25. if /I not "%1" == "" goto DoSetPath
  26. echo ERROR: Argument '-path' specified without argument for TraceFormat folder.
  27. echo Usage example: mqtrace -path x:\symbols.pri\TraceFormat
  28. goto :eof
  29. :DoSetPath
  30. echo Setting TRACE_FORMAT_SEARCH_PATH to '%1'
  31. set TRACE_FORMAT_SEARCH_PATH=%1&shift
  32. goto :eof
  33. :EndSetPath
  34. @rem
  35. @rem Format binary log file to text file
  36. @rem
  37. if /I "%1" == "-format" shift&goto FormatFile
  38. if /I "%1" == "/format" shift&goto FormatFile
  39. goto EndFormatFile
  40. :FormatFile
  41. if /I not "%TRACE_FORMAT_SEARCH_PATH%" == "" goto DoFormatFile
  42. echo ERROR: Argument '-format' specified without running 'mqtrace -path' first.
  43. echo Usage example: mqtrace -path x:\symbols.pri\TraceFormat
  44. echo mqtrace -format ('msmqlog.bin' to text file 'msmqlog.txt')
  45. goto :eof
  46. :DoFormatFile
  47. set mqBinaryLog=msmqlog.bin
  48. if /I not "%1" == "" set mqBinaryLog=%1&shift
  49. echo Formatting binary log file '%mqBinaryLog%' to 'msmqlog.txt'.
  50. call tracefmt %mqBinaryLog% -o msmqlog.txt
  51. set mqBinaryLog=
  52. goto :eof
  53. :EndFormatFile
  54. @rem
  55. @rem Consume the -rt argument
  56. @rem
  57. set mqRealTime=
  58. if /I "%1" == "-rt" shift&goto ConsumeRealTimeArgument
  59. if /I "%1" == "/rt" shift&goto ConsumeRealTimeArgument
  60. goto EndConsumeRealTimeArgument
  61. :ConsumeRealTimeArgument
  62. if /I not "%TRACE_FORMAT_SEARCH_PATH%" == "" goto DoConsumeRealTimeArgument
  63. echo ERROR: Argument '-rt' specified without running 'mqtrace -path' first.
  64. echo Usage example: mqtrace -path x:\symbols.pri\TraceFormat
  65. echo mqtrace -rt (start RealTime logging/formatting at Error level)
  66. goto :eof
  67. :DoConsumeRealTimeArgument
  68. echo Running MSMQ trace in Real Time mode...
  69. set mqRealTime=-rt
  70. :EndConsumeRealTimeArgument
  71. @rem
  72. @rem Handle the -stop argument
  73. @rem
  74. if /I "%1" == "-stop" shift&goto HandleStopArgument
  75. if /I "%1" == "/stop" shift&goto HandleStopArgument
  76. goto EndHandleStopArgument
  77. :HandleStopArgument
  78. echo Stopping MSMQ trace...
  79. call tracelog -stop msmq
  80. goto :eof
  81. :EndHandleStopArgument
  82. @rem
  83. @rem Consume the "-start" argument if it exists. Default is to start.
  84. @rem
  85. echo Starting MSMQ trace logging to 'msmqlog.bin'...
  86. if /I "%1" == "-start" shift
  87. if /I "%1" == "/start" shift
  88. @rem
  89. @rem Process the noise level argument if it exists. Default is error level.
  90. @rem
  91. if /I "%1" == "-info" shift&goto ConsumeInfoArgument
  92. if /I "%1" == "/info" shift&goto ConsumeInfoArgument
  93. goto EndConsumeInfoArgument
  94. :ConsumeInfoArgument
  95. echo MSMQ trace noise level is INFORMATION...
  96. set mqFlags=0x7
  97. goto EndConsumeNoiseLevelArgument
  98. :EndConsumeInfoArgument
  99. if /I "%1" == "-warning" shift&goto ConsumeWarningArgument
  100. if /I "%1" == "/warning" shift&goto ConsumeWarningArgument
  101. goto EndConsumeWarningArgument
  102. :ConsumeWarningArgument
  103. echo MSMQ trace noise level is WARNING...
  104. set mqFlags=0x3
  105. goto EndConsumeNoiseLevelArgument
  106. :EndConsumeWarningArgument
  107. echo MSMQ trace noise level is ERROR...
  108. set mqFlags=0x1
  109. if /I "%1" == "-error" shift
  110. if /I "%1" == "/error" shift
  111. :EndConsumeNoiseLevelArgument
  112. @rem
  113. @rem At this point if we have any argument it's an error
  114. @rem
  115. if /I not "%1" == "" goto Usage
  116. @rem
  117. @rem Query if MSMQ logger is running. If so only update the flags and append to logfile.
  118. @rem
  119. echo Querying if MSMQ logger is currently running...
  120. call tracelog -q msmq
  121. if ERRORLEVEL 1 goto LoggerNotRunning
  122. echo MSMQ logger is currently running, appending new trace output...
  123. set mqStartLogger=-enable
  124. set mqOpenLogfile=-append
  125. goto EndQueryLogger
  126. :LoggerNotRunning
  127. echo MSMQ logger is not currently running, starting new logger...
  128. set mqStartLogger=-start
  129. set mqOpenLogfile=-f
  130. :EndQueryLogger
  131. @rem
  132. @rem Start a new MSMQ logger or update the existing one
  133. @rem
  134. call tracelog %mqStartLogger% msmq %mqRealTime% -ft 1 -flags %mqFlags% %mqOpenLogfile% msmqlog.bin -guid #24b9a175-8716-40e0-9b2b-785de75b1e67
  135. set mqFlags=
  136. set mqStartLogger=
  137. set mqOpenLogfile=
  138. @rem
  139. @rem In real time mode, start formatting
  140. @rem
  141. if /I "%mqRealTime%" == "" goto EndRealTimeFormat
  142. echo Starting MSMQ real time formatting...
  143. call tracefmt -display -rt msmq -o msmqlog.txt
  144. :EndRealTimeFormat
  145. set mqRealTime=
  146. goto :eof
  147. :Usage
  148. echo.
  149. echo Usage: mqtrace [^<Action^>] [^<Level^>]
  150. echo mqtrace -?
  151. echo.
  152. echo Advance Usage: mqtrace -path ^<TraceFormat folder^>
  153. echo mqtrace -rt [^<Action^>] [^<Level^>]
  154. echo mqtrace -format [^<Binary log file^>]
  155. echo.
  156. echo ^<Action^> - Optional trace action:
  157. echo -start - start/update trace logging to 'msmqlog.bin' (default).
  158. echo -stop - stop trace logging.
  159. echo.
  160. echo ^<Level^> - Optional trace level (overrides current trace level):
  161. echo -error - trace error messages only (default).
  162. echo -warning - trace warning and error messages.
  163. echo -info - trace information, warning and error messages.
  164. echo.
  165. echo -? - Display this usage message.
  166. echo.
  167. echo -path - Set environment variable for TraceFormat folder.
  168. echo This variable is necessary for later use of -rt or -format
  169. echo and needs to be set once (per command-line box).
  170. echo.
  171. echo -rt - Start trace logger and formatter in Real Time mode.
  172. echo Environment variable must be set first, see '-path'.
  173. echo In addition, binary log is kept in 'msmqlog.bin'.
  174. echo.
  175. echo -format - Format binary log file to text file 'msmqlog.txt'.
  176. echo Environment variable must be set first, see '-path'.
  177. echo.
  178. echo ^<Binary log file^> - Optional binary log file. Default is 'msmqlog.bin'.
  179. echo.
  180. echo Example 1: mqtrace (start/update logging to 'msmqlog.bin' at Error level)
  181. echo Example 2: mqtrace -path x:\Symbols.pri\TraceFormat
  182. echo Example 3: mqtrace -rt -info (start real time logging at Info level)
  183. echo Example 4: mqtrace -format (format 'msmqlog.bin' to 'msmqlog.txt')
  184. echo Example 5: mqtrace -stop (stop logging)