diff --git a/OnTopReplica/AspectRatioForm.cs b/OnTopReplica/AspectRatioForm.cs index 1301c52..499dd4d 100644 --- a/OnTopReplica/AspectRatioForm.cs +++ b/OnTopReplica/AspectRatioForm.cs @@ -135,7 +135,7 @@ namespace OnTopReplica { AspectRatio = ((double)aspectRatioSource.Width / (double)aspectRatioSource.Height); _keepAspectRatio = true; - Log.Write("Setting new aspect ratio {0} (for {1})", AspectRatio, aspectRatioSource); + //Log.Write("Setting new aspect ratio {0} (for {1})", AspectRatio, aspectRatioSource); if (forceRefresh) { RefreshAspectRatio(); diff --git a/OnTopReplica/Log.cs b/OnTopReplica/Log.cs index 8d0bdb8..0dbeda1 100644 --- a/OnTopReplica/Log.cs +++ b/OnTopReplica/Log.cs @@ -48,28 +48,52 @@ namespace OnTopReplica { WriteLines(message, exception.ToString()); } else { - WriteLines(message, "(no last exception)"); + WriteLines(message, "(No exception data.)"); } } private static void WriteLine(string message) { - if (Writer == null) - return; - var s = string.Format("{0,-8:HH:mm:ss} {1}", DateTime.Now, message); - Writer.WriteLine(s); + AddToQueue(s); + + if (Writer != null) { + Writer.WriteLine(s); + } } private static void WriteLines(params string[] messages) { - if (Writer == null) + if (messages.Length <= 0) return; - if (messages.Length > 0) - WriteLine(messages[0]); - if (messages.Length > 1) { - for (int i = 1; i < messages.Length; ++i) { - Writer.WriteLine(" {0}", messages[i]); - } + var sb = new StringBuilder(); + sb.AppendFormat("{0,-8:HH:mm:ss} {1}", DateTime.Now, messages[0]); + for (int i = 1; i < messages.Length; ++i) { + sb.AppendLine(); + sb.AppendFormat(" {0}", messages[i]); + } + + AddToQueue(sb.ToString()); + + if (Writer != null) { + Writer.WriteLine(sb.ToString()); + } + } + + const int MaxQueueCapacity = 30; + + private static Queue _entriesQueue = new Queue(MaxQueueCapacity); + + private static void AddToQueue(string entry){ + _entriesQueue.Enqueue(entry); + + while(_entriesQueue.Count > MaxQueueCapacity){ + _entriesQueue.Dequeue(); + } + } + + public static IEnumerable Queue { + get { + return _entriesQueue; } } diff --git a/OnTopReplica/MainForm.cs b/OnTopReplica/MainForm.cs index a1e6305..921e84a 100644 --- a/OnTopReplica/MainForm.cs +++ b/OnTopReplica/MainForm.cs @@ -53,6 +53,8 @@ namespace OnTopReplica { //Set to Key event preview this.KeyPreview = true; + + Log.Write("Main form constructed"); } #region Event override @@ -77,6 +79,7 @@ namespace OnTopReplica { } protected override void OnShown(EventArgs e) { + Log.Write("Main form shown"); base.OnShown(e); //Apply startup options @@ -84,10 +87,16 @@ namespace OnTopReplica { } protected override void OnClosing(CancelEventArgs e) { + Log.Write("Main form closing"); + base.OnClosing(e); + _msgPumpManager.Dispose(); Program.Platform.CloseForm(this); + } - base.OnClosing(e); + protected override void OnClosed(EventArgs e) { + Log.Write("Main form closed"); + base.OnClosed(e); } protected override void OnMove(EventArgs e) { diff --git a/OnTopReplica/OnTopReplica.csproj b/OnTopReplica/OnTopReplica.csproj index d682555..e5c5e0c 100644 --- a/OnTopReplica/OnTopReplica.csproj +++ b/OnTopReplica/OnTopReplica.csproj @@ -523,72 +523,72 @@ False + Exclude + True - Exclude - True File False + Exclude + True - Exclude - True File False + Exclude + True - Exclude - True File False + Exclude + True - Exclude - True File False + Include + True - Include - True Satellite False + Include + True - Include - True Satellite False + Include + True - Include - True Satellite diff --git a/OnTopReplica/Program.cs b/OnTopReplica/Program.cs index 73b0846..530d514 100644 --- a/OnTopReplica/Program.cs +++ b/OnTopReplica/Program.cs @@ -114,7 +114,7 @@ namespace OnTopReplica { /// static void UpdateManager_CheckCompleted(object sender, UpdateCheckCompletedEventArgs e) { if (e.Success && e.Information != null) { - Log.Write("Updated check successful (latest version is {0})", e.Information.LatestVersion); + Log.Write("Update check successful (latest version is {0})", e.Information.LatestVersion); if (e.Information.IsNewVersionAvailable) { Update.ConfirmAndInstall(); @@ -139,6 +139,11 @@ namespace OnTopReplica { sw.WriteLine("Last exception:"); sw.WriteLine(e.ExceptionObject.ToString()); sw.WriteLine(); + sw.WriteLine("Last log entries:"); + foreach (var logEntry in Log.Queue) { + sw.WriteLine(logEntry); + } + sw.WriteLine(); sw.WriteLine("OnTopReplica v.{0}", Application.ProductVersion); sw.WriteLine("OS: {0}", Environment.OSVersion.ToString()); sw.WriteLine(".NET: {0}", Environment.Version.ToString());