Merge pull request #1455 from dotnet/pakrym/timespan

Log time from build start instead of absolute time
This commit is contained in:
Pavel Krymets 2016-02-17 21:29:37 -08:00
commit 6f0e52376e

View file

@ -4,9 +4,12 @@ namespace Microsoft.DotNet.Cli.Build.Framework
{ {
public static class BuildReporter public static class BuildReporter
{ {
private const string TimeSpanFormat = @"hh\:mm\:ss\.fff";
private static DateTime _initialTime = DateTime.Now;
public static void BeginSection(string type, string name) public static void BeginSection(string type, string name)
{ {
Reporter.Output.WriteLine($"[{type.PadRight(10)} >]".Green() + $" [....] [{DateTime.Now:O}]".Blue() + $" {name}"); Reporter.Output.WriteLine($"[{type.PadRight(10)} >]".Green() + $" [....] [{(DateTime.Now - _initialTime).ToString(TimeSpanFormat)}]".Blue() + $" {name}");
} }
public static void EndSection(string type, string name, bool success) public static void EndSection(string type, string name, bool success)
@ -21,7 +24,7 @@ namespace Microsoft.DotNet.Cli.Build.Framework
header = header.Red(); header = header.Red();
} }
var successString = success ? " OK " : "FAIL"; var successString = success ? " OK " : "FAIL";
Reporter.Output.WriteLine(header + $" [{successString}] [{DateTime.Now:O}]".Blue() + $" {name}"); Reporter.Output.WriteLine(header + $" [{successString}] [{(DateTime.Now - _initialTime).ToString(TimeSpanFormat)}]".Blue() + $" {name}");
} }
} }
} }