mirror of
https://github.com/LorenzCK/OnTopReplica.git
synced 2024-05-10 07:22:29 +12:00
Improved unhandled exception handling (now writer last log entries to crash dump file).
This commit is contained in:
parent
4bf654807e
commit
9d97da10c9
|
@ -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();
|
||||
|
|
|
@ -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<string> _entriesQueue = new Queue<string>(MaxQueueCapacity);
|
||||
|
||||
private static void AddToQueue(string entry){
|
||||
_entriesQueue.Enqueue(entry);
|
||||
|
||||
while(_entriesQueue.Count > MaxQueueCapacity){
|
||||
_entriesQueue.Dequeue();
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<string> Queue {
|
||||
get {
|
||||
return _entriesQueue;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -523,72 +523,72 @@
|
|||
<ItemGroup>
|
||||
<PublishFile Include="Assets\icon.ico">
|
||||
<Visible>False</Visible>
|
||||
<PublishState>Exclude</PublishState>
|
||||
<IncludeHash>True</IncludeHash>
|
||||
<Group>
|
||||
</Group>
|
||||
<TargetPath>
|
||||
</TargetPath>
|
||||
<PublishState>Exclude</PublishState>
|
||||
<IncludeHash>True</IncludeHash>
|
||||
<FileType>File</FileType>
|
||||
</PublishFile>
|
||||
<PublishFile Include="Assets\screenshot-icon.ico">
|
||||
<Visible>False</Visible>
|
||||
<PublishState>Exclude</PublishState>
|
||||
<IncludeHash>True</IncludeHash>
|
||||
<Group>
|
||||
</Group>
|
||||
<TargetPath>
|
||||
</TargetPath>
|
||||
<PublishState>Exclude</PublishState>
|
||||
<IncludeHash>True</IncludeHash>
|
||||
<FileType>File</FileType>
|
||||
</PublishFile>
|
||||
<PublishFile Include="Assets\window_multiple16.ico">
|
||||
<Visible>False</Visible>
|
||||
<PublishState>Exclude</PublishState>
|
||||
<IncludeHash>True</IncludeHash>
|
||||
<Group>
|
||||
</Group>
|
||||
<TargetPath>
|
||||
</TargetPath>
|
||||
<PublishState>Exclude</PublishState>
|
||||
<IncludeHash>True</IncludeHash>
|
||||
<FileType>File</FileType>
|
||||
</PublishFile>
|
||||
<PublishFile Include="Assets\xiao_arrow.png">
|
||||
<Visible>False</Visible>
|
||||
<PublishState>Exclude</PublishState>
|
||||
<IncludeHash>True</IncludeHash>
|
||||
<Group>
|
||||
</Group>
|
||||
<TargetPath>
|
||||
</TargetPath>
|
||||
<PublishState>Exclude</PublishState>
|
||||
<IncludeHash>True</IncludeHash>
|
||||
<FileType>File</FileType>
|
||||
</PublishFile>
|
||||
<PublishFile Include="cs\OnTopReplica.resources">
|
||||
<Visible>False</Visible>
|
||||
<PublishState>Include</PublishState>
|
||||
<IncludeHash>True</IncludeHash>
|
||||
<Group>
|
||||
</Group>
|
||||
<TargetPath>
|
||||
</TargetPath>
|
||||
<PublishState>Include</PublishState>
|
||||
<IncludeHash>True</IncludeHash>
|
||||
<FileType>Satellite</FileType>
|
||||
</PublishFile>
|
||||
<PublishFile Include="da\OnTopReplica.resources">
|
||||
<Visible>False</Visible>
|
||||
<PublishState>Include</PublishState>
|
||||
<IncludeHash>True</IncludeHash>
|
||||
<Group>
|
||||
</Group>
|
||||
<TargetPath>
|
||||
</TargetPath>
|
||||
<PublishState>Include</PublishState>
|
||||
<IncludeHash>True</IncludeHash>
|
||||
<FileType>Satellite</FileType>
|
||||
</PublishFile>
|
||||
<PublishFile Include="it\OnTopReplica.resources">
|
||||
<Visible>False</Visible>
|
||||
<PublishState>Include</PublishState>
|
||||
<IncludeHash>True</IncludeHash>
|
||||
<Group>
|
||||
</Group>
|
||||
<TargetPath>
|
||||
</TargetPath>
|
||||
<PublishState>Include</PublishState>
|
||||
<IncludeHash>True</IncludeHash>
|
||||
<FileType>Satellite</FileType>
|
||||
</PublishFile>
|
||||
</ItemGroup>
|
||||
|
|
|
@ -114,7 +114,7 @@ namespace OnTopReplica {
|
|||
/// </summary>
|
||||
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());
|
||||
|
|
Loading…
Reference in a new issue