Added a debug tool to view and manage log files. Slight tweaks to the main form as well as the thread exception methods.

This commit is contained in:
2017-04-14 01:24:50 -05:00
parent 7b2a93cbf6
commit c334c9aa53
7 changed files with 6594 additions and 20 deletions
+11 -14
View File
@@ -1,25 +1,22 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AdvertsingProfitControl
{
class GlobalClasses
internal class GlobalClasses
{
public static string LogFilePath = @"C:\Users\" + Environment.UserName + @"\AppData\Local\APC\";
public static void LogError(object sender, System.Threading.ThreadExceptionEventArgs e)
{
using (
StreamWriter file =
var file =
new StreamWriter(@"C:\Users\" + Environment.UserName + @"\AppData\Local\APC\" + DateTime.Now.ToString("MM-dd-yyyy") + ".log", true))
{
file.WriteLine(DateTime.Now + ": Unhandled Thread Exception:\n" + e.Exception.Message + "\n" + e.Exception.StackTrace);
MessageBox.Show("An unhandled thread exception has occurred. Advertising Profit Control will be forced to exit.",
"Fatal Error");
file.WriteLine(DateTime.Now + ": Unhandled Thread Exception:\n" + e.Exception.Message + Environment.NewLine);
MessageBox.Show(@"An unhandled thread exception has occurred. Advertising Profit Control will be forced to exit.",
@"Fatal Error");
Application.Exit();
}
}
@@ -27,12 +24,12 @@ namespace AdvertsingProfitControl
public static void LogError(object sender, UnhandledExceptionEventArgs e)
{
using (
StreamWriter file =
var file =
new StreamWriter(@"C:\Users\" + Environment.UserName + @"\AppData\Local\APC\" + DateTime.Now.ToString("MM-dd-yyyy") + ".log", true))
{
file.WriteLine(DateTime.Now + ": An unhandled exception occurred. \nException Object: " + e.ExceptionObject);
MessageBox.Show("And unknown error has occurred. Advertising Profit Control will be forced to exit.",
"Fatal Error");
file.WriteLine(DateTime.Now + ": An unhandled exception occurred. \nException Object: " + e.ExceptionObject + Environment.NewLine);
MessageBox.Show(@"And unknown error has occurred. Advertising Profit Control will be forced to exit.",
@"Fatal Error");
Application.Exit();
}
}
@@ -40,7 +37,7 @@ namespace AdvertsingProfitControl
public static void WriteToLog(string message)
{
using (
StreamWriter file =
var file =
new StreamWriter(@"C:\Users\" + Environment.UserName + @"\AppData\Local\APC\Information.log", true))
{
file.WriteLine(message);