Skip to content

Commit

Permalink
Display rundown information when stopping trace (#721)
Browse files Browse the repository at this point in the history
  • Loading branch information
sywhang authored Dec 24, 2019
1 parent 76c0af2 commit 1590aaa
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/Tools/dotnet-trace/CommandLine/Commands/CollectCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ private static async Task<int> Collect(CancellationToken ct, IConsole console, i
var shouldStopAfterDuration = duration != default(TimeSpan);
var failed = false;
var terminated = false;
var rundownRequested = false;
System.Timers.Timer durationTimer = null;

ct.Register(() => shouldExit.Set());
Expand Down Expand Up @@ -152,15 +153,18 @@ private static async Task<int> Collect(CancellationToken ct, IConsole console, i
break;
fs.Write(buffer, 0, nBytesRead);

if (hasConsole)
if (!rundownRequested)
{
lineToClear = Console.CursorTop - 1;
ResetCurrentConsoleLine(vTermMode.IsEnabled);
if (hasConsole)
{
lineToClear = Console.CursorTop - 1;
ResetCurrentConsoleLine(vTermMode.IsEnabled);
}

Console.Out.WriteLine($"[{stopwatch.Elapsed.ToString(@"dd\:hh\:mm\:ss")}]\tRecording trace {GetSize(fs.Length)}");
Console.Out.WriteLine("Press <Enter> or <Ctrl+C> to exit...");
Debug.WriteLine($"PACKET: {Convert.ToBase64String(buffer, 0, nBytesRead)} (bytes {nBytesRead})");
}

Console.Out.WriteLine($"[{stopwatch.Elapsed.ToString(@"dd\:hh\:mm\:ss")}]\tRecording trace {GetSize(fs.Length)}");
Console.Out.WriteLine("Press <Enter> or <Ctrl+C> to exit...");
Debug.WriteLine($"PACKET: {Convert.ToBase64String(buffer, 0, nBytesRead)} (bytes {nBytesRead})");
}
}
}
Expand All @@ -185,6 +189,13 @@ private static async Task<int> Collect(CancellationToken ct, IConsole console, i
if (!terminated)
{
durationTimer?.Stop();
if (hasConsole)
{
lineToClear = Console.CursorTop;
ResetCurrentConsoleLine(vTermMode.IsEnabled);
}
Console.Out.WriteLine("Stopping the trace. This may take up to minutes depending on the application being traced.");
rundownRequested = true;
session.Stop();
}
await collectingTask;
Expand Down

0 comments on commit 1590aaa

Please sign in to comment.