[Logger, Stats] Add suppression of end runtime

This commit is contained in:
Matt Nadareski
2016-06-13 00:40:32 -07:00
parent 091a3ba4aa
commit 5325b711de
2 changed files with 32 additions and 18 deletions

View File

@@ -85,28 +85,42 @@ namespace SabreTools.Helper
/// <summary> /// <summary>
/// End logging by closing output file (if necessary) /// End logging by closing output file (if necessary)
/// </summary> /// </summary>
/// <param name="suppress">True if all ending output is to be suppressed, false otherwise (default)</param>
/// <returns>True if the logging was ended correctly, false otherwise</returns> /// <returns>True if the logging was ended correctly, false otherwise</returns>
public bool Close() public bool Close(bool suppress = false)
{ {
if (!suppress)
{
TimeSpan span = DateTime.Now.Subtract(_start);
string total = span.ToString(@"hh\:mm\:ss\.fffff");
if (!_tofile)
{
Console.WriteLine("Total runtime: " + total);
return true;
}
TimeSpan span = DateTime.Now.Subtract(_start); try
string total = span.ToString(@"hh\:mm\:ss\.fffff"); {
if (!_tofile) _log.WriteLine("Logging ended " + DateTime.Now);
{ _log.WriteLine("Total runtime: " + total);
Console.WriteLine("Total runtime: " + total); Console.WriteLine("Total runtime: " + total);
return true; _log.Close();
}
catch
{
return false;
}
} }
else
try
{ {
_log.WriteLine("Logging ended " + DateTime.Now); try
_log.WriteLine("Total runtime: " + total); {
Console.WriteLine("Total runtime: " + total); _log.Close();
_log.Close(); }
} catch
catch {
{ return false;
return false; }
} }
return true; return true;

View File

@@ -553,7 +553,7 @@ namespace SabreTools
statlog.Start(); statlog.Start();
Stats stats = new Stats(newinputs, single, statlog); Stats stats = new Stats(newinputs, single, statlog);
stats.Process(); stats.Process();
statlog.Close(); statlog.Close(true);
} }
/// <summary> /// <summary>