Skip to content

Commit

Permalink
potentially fix deletion of old log files, show message if HDT is alr…
Browse files Browse the repository at this point in the history
…eady running instead of silently closing it
  • Loading branch information
Epix37 committed Oct 29, 2015
1 parent 861b0de commit 95ff67c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Hearthstone Deck Tracker/Utility/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ internal static void Initialzie()
//keep logs from the last 2 days plus 25 before that
foreach(var file in
new DirectoryInfo(logDir).GetFiles("hdt_log*")
.Where(x => x.CreationTime < DateTime.Now.AddDays(-MaxLogFileAge))
.OrderByDescending(x => x.CreationTime)
.Where(x => x.LastWriteTime < DateTime.Now.AddDays(-MaxLogFileAge))
.OrderByDescending(x => x.LastWriteTime)
.Skip(KeepOldLogs))
{
try
Expand All @@ -61,6 +61,7 @@ internal static void Initialzie()
var errLogFile = Path.Combine(logDir, "hdt_log_err.txt");
using(var writer = new StreamWriter(errLogFile, true))
writer.WriteLine("[{0}]: {1}", DateTime.Now.ToLongTimeString(), "Another instance of HDT is already running.");
MessageBox.Show("Another instance of Hearthstone Deck Tracker is already running.", "Error starting Hearthstone Deck Tracker", MessageBoxButton.OK, MessageBoxImage.Error);
}
catch(Exception)
{
Expand Down

0 comments on commit 95ff67c

Please sign in to comment.