mirror of
https://github.com/LorenzCK/OnTopReplica.git
synced 2024-05-20 20:33:06 +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);
|
AspectRatio = ((double)aspectRatioSource.Width / (double)aspectRatioSource.Height);
|
||||||
_keepAspectRatio = true;
|
_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) {
|
if (forceRefresh) {
|
||||||
RefreshAspectRatio();
|
RefreshAspectRatio();
|
||||||
|
|
|
@ -48,28 +48,52 @@ namespace OnTopReplica {
|
||||||
WriteLines(message, exception.ToString());
|
WriteLines(message, exception.ToString());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
WriteLines(message, "(no last exception)");
|
WriteLines(message, "(No exception data.)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void WriteLine(string message) {
|
private static void WriteLine(string message) {
|
||||||
if (Writer == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var s = string.Format("{0,-8:HH:mm:ss} {1}", DateTime.Now, message);
|
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) {
|
private static void WriteLines(params string[] messages) {
|
||||||
if (Writer == null)
|
if (messages.Length <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (messages.Length > 0)
|
var sb = new StringBuilder();
|
||||||
WriteLine(messages[0]);
|
sb.AppendFormat("{0,-8:HH:mm:ss} {1}", DateTime.Now, messages[0]);
|
||||||
if (messages.Length > 1) {
|
for (int i = 1; i < messages.Length; ++i) {
|
||||||
for (int i = 1; i < messages.Length; ++i) {
|
sb.AppendLine();
|
||||||
Writer.WriteLine(" {0}", messages[i]);
|
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
|
//Set to Key event preview
|
||||||
this.KeyPreview = true;
|
this.KeyPreview = true;
|
||||||
|
|
||||||
|
Log.Write("Main form constructed");
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Event override
|
#region Event override
|
||||||
|
@ -77,6 +79,7 @@ namespace OnTopReplica {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnShown(EventArgs e) {
|
protected override void OnShown(EventArgs e) {
|
||||||
|
Log.Write("Main form shown");
|
||||||
base.OnShown(e);
|
base.OnShown(e);
|
||||||
|
|
||||||
//Apply startup options
|
//Apply startup options
|
||||||
|
@ -84,10 +87,16 @@ namespace OnTopReplica {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnClosing(CancelEventArgs e) {
|
protected override void OnClosing(CancelEventArgs e) {
|
||||||
|
Log.Write("Main form closing");
|
||||||
|
base.OnClosing(e);
|
||||||
|
|
||||||
_msgPumpManager.Dispose();
|
_msgPumpManager.Dispose();
|
||||||
Program.Platform.CloseForm(this);
|
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) {
|
protected override void OnMove(EventArgs e) {
|
||||||
|
|
|
@ -523,72 +523,72 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PublishFile Include="Assets\icon.ico">
|
<PublishFile Include="Assets\icon.ico">
|
||||||
<Visible>False</Visible>
|
<Visible>False</Visible>
|
||||||
|
<PublishState>Exclude</PublishState>
|
||||||
|
<IncludeHash>True</IncludeHash>
|
||||||
<Group>
|
<Group>
|
||||||
</Group>
|
</Group>
|
||||||
<TargetPath>
|
<TargetPath>
|
||||||
</TargetPath>
|
</TargetPath>
|
||||||
<PublishState>Exclude</PublishState>
|
|
||||||
<IncludeHash>True</IncludeHash>
|
|
||||||
<FileType>File</FileType>
|
<FileType>File</FileType>
|
||||||
</PublishFile>
|
</PublishFile>
|
||||||
<PublishFile Include="Assets\screenshot-icon.ico">
|
<PublishFile Include="Assets\screenshot-icon.ico">
|
||||||
<Visible>False</Visible>
|
<Visible>False</Visible>
|
||||||
|
<PublishState>Exclude</PublishState>
|
||||||
|
<IncludeHash>True</IncludeHash>
|
||||||
<Group>
|
<Group>
|
||||||
</Group>
|
</Group>
|
||||||
<TargetPath>
|
<TargetPath>
|
||||||
</TargetPath>
|
</TargetPath>
|
||||||
<PublishState>Exclude</PublishState>
|
|
||||||
<IncludeHash>True</IncludeHash>
|
|
||||||
<FileType>File</FileType>
|
<FileType>File</FileType>
|
||||||
</PublishFile>
|
</PublishFile>
|
||||||
<PublishFile Include="Assets\window_multiple16.ico">
|
<PublishFile Include="Assets\window_multiple16.ico">
|
||||||
<Visible>False</Visible>
|
<Visible>False</Visible>
|
||||||
|
<PublishState>Exclude</PublishState>
|
||||||
|
<IncludeHash>True</IncludeHash>
|
||||||
<Group>
|
<Group>
|
||||||
</Group>
|
</Group>
|
||||||
<TargetPath>
|
<TargetPath>
|
||||||
</TargetPath>
|
</TargetPath>
|
||||||
<PublishState>Exclude</PublishState>
|
|
||||||
<IncludeHash>True</IncludeHash>
|
|
||||||
<FileType>File</FileType>
|
<FileType>File</FileType>
|
||||||
</PublishFile>
|
</PublishFile>
|
||||||
<PublishFile Include="Assets\xiao_arrow.png">
|
<PublishFile Include="Assets\xiao_arrow.png">
|
||||||
<Visible>False</Visible>
|
<Visible>False</Visible>
|
||||||
|
<PublishState>Exclude</PublishState>
|
||||||
|
<IncludeHash>True</IncludeHash>
|
||||||
<Group>
|
<Group>
|
||||||
</Group>
|
</Group>
|
||||||
<TargetPath>
|
<TargetPath>
|
||||||
</TargetPath>
|
</TargetPath>
|
||||||
<PublishState>Exclude</PublishState>
|
|
||||||
<IncludeHash>True</IncludeHash>
|
|
||||||
<FileType>File</FileType>
|
<FileType>File</FileType>
|
||||||
</PublishFile>
|
</PublishFile>
|
||||||
<PublishFile Include="cs\OnTopReplica.resources">
|
<PublishFile Include="cs\OnTopReplica.resources">
|
||||||
<Visible>False</Visible>
|
<Visible>False</Visible>
|
||||||
|
<PublishState>Include</PublishState>
|
||||||
|
<IncludeHash>True</IncludeHash>
|
||||||
<Group>
|
<Group>
|
||||||
</Group>
|
</Group>
|
||||||
<TargetPath>
|
<TargetPath>
|
||||||
</TargetPath>
|
</TargetPath>
|
||||||
<PublishState>Include</PublishState>
|
|
||||||
<IncludeHash>True</IncludeHash>
|
|
||||||
<FileType>Satellite</FileType>
|
<FileType>Satellite</FileType>
|
||||||
</PublishFile>
|
</PublishFile>
|
||||||
<PublishFile Include="da\OnTopReplica.resources">
|
<PublishFile Include="da\OnTopReplica.resources">
|
||||||
<Visible>False</Visible>
|
<Visible>False</Visible>
|
||||||
|
<PublishState>Include</PublishState>
|
||||||
|
<IncludeHash>True</IncludeHash>
|
||||||
<Group>
|
<Group>
|
||||||
</Group>
|
</Group>
|
||||||
<TargetPath>
|
<TargetPath>
|
||||||
</TargetPath>
|
</TargetPath>
|
||||||
<PublishState>Include</PublishState>
|
|
||||||
<IncludeHash>True</IncludeHash>
|
|
||||||
<FileType>Satellite</FileType>
|
<FileType>Satellite</FileType>
|
||||||
</PublishFile>
|
</PublishFile>
|
||||||
<PublishFile Include="it\OnTopReplica.resources">
|
<PublishFile Include="it\OnTopReplica.resources">
|
||||||
<Visible>False</Visible>
|
<Visible>False</Visible>
|
||||||
|
<PublishState>Include</PublishState>
|
||||||
|
<IncludeHash>True</IncludeHash>
|
||||||
<Group>
|
<Group>
|
||||||
</Group>
|
</Group>
|
||||||
<TargetPath>
|
<TargetPath>
|
||||||
</TargetPath>
|
</TargetPath>
|
||||||
<PublishState>Include</PublishState>
|
|
||||||
<IncludeHash>True</IncludeHash>
|
|
||||||
<FileType>Satellite</FileType>
|
<FileType>Satellite</FileType>
|
||||||
</PublishFile>
|
</PublishFile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -114,7 +114,7 @@ namespace OnTopReplica {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
static void UpdateManager_CheckCompleted(object sender, UpdateCheckCompletedEventArgs e) {
|
static void UpdateManager_CheckCompleted(object sender, UpdateCheckCompletedEventArgs e) {
|
||||||
if (e.Success && e.Information != null) {
|
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) {
|
if (e.Information.IsNewVersionAvailable) {
|
||||||
Update.ConfirmAndInstall();
|
Update.ConfirmAndInstall();
|
||||||
|
@ -139,6 +139,11 @@ namespace OnTopReplica {
|
||||||
sw.WriteLine("Last exception:");
|
sw.WriteLine("Last exception:");
|
||||||
sw.WriteLine(e.ExceptionObject.ToString());
|
sw.WriteLine(e.ExceptionObject.ToString());
|
||||||
sw.WriteLine();
|
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("OnTopReplica v.{0}", Application.ProductVersion);
|
||||||
sw.WriteLine("OS: {0}", Environment.OSVersion.ToString());
|
sw.WriteLine("OS: {0}", Environment.OSVersion.ToString());
|
||||||
sw.WriteLine(".NET: {0}", Environment.Version.ToString());
|
sw.WriteLine(".NET: {0}", Environment.Version.ToString());
|
||||||
|
|
Loading…
Reference in a new issue