feat: greatly improve debugging

This commit is contained in:
NanderTGA 2023-08-12 23:56:04 +02:00
parent 28cde9ab8d
commit eb3c774d47
No known key found for this signature in database
GPG Key ID: 387081A6AADB0C8D
4 changed files with 577 additions and 51 deletions

View File

@ -29,26 +29,81 @@ namespace OpenFK
/// </summary>
private void InitializeComponent()
{
this.generalLog = new System.Windows.Forms.RichTextBox();
this.generalLogs = new System.Windows.Forms.RichTextBox();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.logTab = new System.Windows.Forms.TabPage();
this.FileLogsTab = new System.Windows.Forms.TabPage();
this.fileLogs = new System.Windows.Forms.RichTextBox();
this.incoming = new System.Windows.Forms.TabPage();
this.incomingLogs = new System.Windows.Forms.RichTextBox();
this.outgoing = new System.Windows.Forms.TabPage();
this.outgoingLogs = new System.Windows.Forms.RichTextBox();
this.CLogger = new System.Windows.Forms.TabPage();
this.CLoggerTabControl = new System.Windows.Forms.TabControl();
this.All = new System.Windows.Forms.TabPage();
this.CLoggerAll = new System.Windows.Forms.RichTextBox();
this.Trace = new System.Windows.Forms.TabPage();
this.CLoggerTrace = new System.Windows.Forms.RichTextBox();
this.Debug = new System.Windows.Forms.TabPage();
this.CLoggerDebug = new System.Windows.Forms.RichTextBox();
this.Info = new System.Windows.Forms.TabPage();
this.CLoggerInfo = new System.Windows.Forms.RichTextBox();
this.Warning = new System.Windows.Forms.TabPage();
this.CLoggerWarning = new System.Windows.Forms.RichTextBox();
this.Error = new System.Windows.Forms.TabPage();
this.CLoggerError = new System.Windows.Forms.RichTextBox();
this.Fatal = new System.Windows.Forms.TabPage();
this.CLoggerFatal = new System.Windows.Forms.RichTextBox();
this.network = new System.Windows.Forms.TabPage();
this.NetworkTabs = new System.Windows.Forms.TabControl();
this.NetworkAllTab = new System.Windows.Forms.TabPage();
this.NetworkAllLogs = new System.Windows.Forms.RichTextBox();
this.NetworkGetTab = new System.Windows.Forms.TabPage();
this.NetworkGetLogs = new System.Windows.Forms.RichTextBox();
this.NetworkPostTab = new System.Windows.Forms.TabPage();
this.NetworkPostLogs = new System.Windows.Forms.RichTextBox();
this.NetworkCommandTab = new System.Windows.Forms.TabPage();
this.NetworkCommandLogs = new System.Windows.Forms.RichTextBox();
this.tabControl1.SuspendLayout();
this.logTab.SuspendLayout();
this.FileLogsTab.SuspendLayout();
this.incoming.SuspendLayout();
this.outgoing.SuspendLayout();
this.CLogger.SuspendLayout();
this.CLoggerTabControl.SuspendLayout();
this.All.SuspendLayout();
this.Trace.SuspendLayout();
this.Debug.SuspendLayout();
this.Info.SuspendLayout();
this.Warning.SuspendLayout();
this.Error.SuspendLayout();
this.Fatal.SuspendLayout();
this.network.SuspendLayout();
this.NetworkTabs.SuspendLayout();
this.NetworkAllTab.SuspendLayout();
this.NetworkGetTab.SuspendLayout();
this.NetworkPostTab.SuspendLayout();
this.NetworkCommandTab.SuspendLayout();
this.SuspendLayout();
//
// generalLog
// generalLogs
//
this.generalLog.Dock = System.Windows.Forms.DockStyle.Fill;
this.generalLog.Location = new System.Drawing.Point(3, 3);
this.generalLog.Name = "generalLog";
this.generalLog.ReadOnly = true;
this.generalLog.Size = new System.Drawing.Size(593, 423);
this.generalLog.TabIndex = 0;
this.generalLog.Text = "";
this.generalLogs.Dock = System.Windows.Forms.DockStyle.Fill;
this.generalLogs.Location = new System.Drawing.Point(3, 3);
this.generalLogs.Name = "generalLogs";
this.generalLogs.ReadOnly = true;
this.generalLogs.Size = new System.Drawing.Size(593, 423);
this.generalLogs.TabIndex = 0;
this.generalLogs.Text = "";
//
// tabControl1
//
this.tabControl1.Controls.Add(this.logTab);
this.tabControl1.Controls.Add(this.FileLogsTab);
this.tabControl1.Controls.Add(this.incoming);
this.tabControl1.Controls.Add(this.outgoing);
this.tabControl1.Controls.Add(this.CLogger);
this.tabControl1.Controls.Add(this.network);
this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabControl1.Location = new System.Drawing.Point(0, 0);
this.tabControl1.Name = "tabControl1";
@ -58,7 +113,7 @@ namespace OpenFK
//
// logTab
//
this.logTab.Controls.Add(this.generalLog);
this.logTab.Controls.Add(this.generalLogs);
this.logTab.Location = new System.Drawing.Point(4, 22);
this.logTab.Name = "logTab";
this.logTab.Padding = new System.Windows.Forms.Padding(3);
@ -67,6 +122,344 @@ namespace OpenFK
this.logTab.Text = "Log";
this.logTab.UseVisualStyleBackColor = true;
//
// FileLogsTab
//
this.FileLogsTab.Controls.Add(this.fileLogs);
this.FileLogsTab.Location = new System.Drawing.Point(4, 22);
this.FileLogsTab.Name = "FileLogsTab";
this.FileLogsTab.Padding = new System.Windows.Forms.Padding(3);
this.FileLogsTab.Size = new System.Drawing.Size(599, 429);
this.FileLogsTab.TabIndex = 1;
this.FileLogsTab.Text = "File Logs";
this.FileLogsTab.UseVisualStyleBackColor = true;
//
// fileLogs
//
this.fileLogs.Dock = System.Windows.Forms.DockStyle.Fill;
this.fileLogs.Location = new System.Drawing.Point(3, 3);
this.fileLogs.Name = "fileLogs";
this.fileLogs.ReadOnly = true;
this.fileLogs.Size = new System.Drawing.Size(593, 423);
this.fileLogs.TabIndex = 0;
this.fileLogs.Text = "";
//
// incoming
//
this.incoming.Controls.Add(this.incomingLogs);
this.incoming.Location = new System.Drawing.Point(4, 22);
this.incoming.Name = "incoming";
this.incoming.Padding = new System.Windows.Forms.Padding(3);
this.incoming.Size = new System.Drawing.Size(599, 429);
this.incoming.TabIndex = 3;
this.incoming.Text = "Incoming";
this.incoming.UseVisualStyleBackColor = true;
//
// incomingLogs
//
this.incomingLogs.Dock = System.Windows.Forms.DockStyle.Fill;
this.incomingLogs.Location = new System.Drawing.Point(3, 3);
this.incomingLogs.Name = "incomingLogs";
this.incomingLogs.ReadOnly = true;
this.incomingLogs.Size = new System.Drawing.Size(593, 423);
this.incomingLogs.TabIndex = 0;
this.incomingLogs.Text = "";
//
// outgoing
//
this.outgoing.Controls.Add(this.outgoingLogs);
this.outgoing.Location = new System.Drawing.Point(4, 22);
this.outgoing.Name = "outgoing";
this.outgoing.Size = new System.Drawing.Size(599, 429);
this.outgoing.TabIndex = 4;
this.outgoing.Text = "Outgoing";
this.outgoing.UseVisualStyleBackColor = true;
//
// outgoingLogs
//
this.outgoingLogs.Dock = System.Windows.Forms.DockStyle.Fill;
this.outgoingLogs.Location = new System.Drawing.Point(0, 0);
this.outgoingLogs.Name = "outgoingLogs";
this.outgoingLogs.ReadOnly = true;
this.outgoingLogs.Size = new System.Drawing.Size(599, 429);
this.outgoingLogs.TabIndex = 0;
this.outgoingLogs.Text = "";
//
// CLogger
//
this.CLogger.Controls.Add(this.CLoggerTabControl);
this.CLogger.Location = new System.Drawing.Point(4, 22);
this.CLogger.Name = "CLogger";
this.CLogger.Padding = new System.Windows.Forms.Padding(3);
this.CLogger.Size = new System.Drawing.Size(599, 429);
this.CLogger.TabIndex = 5;
this.CLogger.Text = "CLogger";
this.CLogger.UseVisualStyleBackColor = true;
//
// CLoggerTabControl
//
this.CLoggerTabControl.Controls.Add(this.All);
this.CLoggerTabControl.Controls.Add(this.Trace);
this.CLoggerTabControl.Controls.Add(this.Debug);
this.CLoggerTabControl.Controls.Add(this.Info);
this.CLoggerTabControl.Controls.Add(this.Warning);
this.CLoggerTabControl.Controls.Add(this.Error);
this.CLoggerTabControl.Controls.Add(this.Fatal);
this.CLoggerTabControl.Dock = System.Windows.Forms.DockStyle.Fill;
this.CLoggerTabControl.Location = new System.Drawing.Point(3, 3);
this.CLoggerTabControl.Name = "CLoggerTabControl";
this.CLoggerTabControl.SelectedIndex = 0;
this.CLoggerTabControl.Size = new System.Drawing.Size(593, 423);
this.CLoggerTabControl.TabIndex = 0;
//
// All
//
this.All.Controls.Add(this.CLoggerAll);
this.All.Location = new System.Drawing.Point(4, 22);
this.All.Name = "All";
this.All.Padding = new System.Windows.Forms.Padding(3);
this.All.Size = new System.Drawing.Size(585, 397);
this.All.TabIndex = 0;
this.All.Text = "All";
this.All.UseVisualStyleBackColor = true;
//
// CLoggerAll
//
this.CLoggerAll.Dock = System.Windows.Forms.DockStyle.Fill;
this.CLoggerAll.Location = new System.Drawing.Point(3, 3);
this.CLoggerAll.Name = "CLoggerAll";
this.CLoggerAll.ReadOnly = true;
this.CLoggerAll.Size = new System.Drawing.Size(579, 391);
this.CLoggerAll.TabIndex = 0;
this.CLoggerAll.Text = "";
//
// Trace
//
this.Trace.Controls.Add(this.CLoggerTrace);
this.Trace.Location = new System.Drawing.Point(4, 22);
this.Trace.Name = "Trace";
this.Trace.Padding = new System.Windows.Forms.Padding(3);
this.Trace.Size = new System.Drawing.Size(585, 397);
this.Trace.TabIndex = 1;
this.Trace.Text = "Trace";
this.Trace.UseVisualStyleBackColor = true;
//
// CLoggerTrace
//
this.CLoggerTrace.Dock = System.Windows.Forms.DockStyle.Fill;
this.CLoggerTrace.Location = new System.Drawing.Point(3, 3);
this.CLoggerTrace.Name = "CLoggerTrace";
this.CLoggerTrace.ReadOnly = true;
this.CLoggerTrace.Size = new System.Drawing.Size(579, 391);
this.CLoggerTrace.TabIndex = 1;
this.CLoggerTrace.Text = "";
//
// Debug
//
this.Debug.Controls.Add(this.CLoggerDebug);
this.Debug.Location = new System.Drawing.Point(4, 22);
this.Debug.Name = "Debug";
this.Debug.Size = new System.Drawing.Size(585, 397);
this.Debug.TabIndex = 2;
this.Debug.Text = "Debug";
this.Debug.UseVisualStyleBackColor = true;
//
// CLoggerDebug
//
this.CLoggerDebug.Dock = System.Windows.Forms.DockStyle.Fill;
this.CLoggerDebug.Location = new System.Drawing.Point(0, 0);
this.CLoggerDebug.Name = "CLoggerDebug";
this.CLoggerDebug.ReadOnly = true;
this.CLoggerDebug.Size = new System.Drawing.Size(585, 397);
this.CLoggerDebug.TabIndex = 1;
this.CLoggerDebug.Text = "";
//
// Info
//
this.Info.Controls.Add(this.CLoggerInfo);
this.Info.Location = new System.Drawing.Point(4, 22);
this.Info.Name = "Info";
this.Info.Size = new System.Drawing.Size(585, 397);
this.Info.TabIndex = 3;
this.Info.Text = "Info";
this.Info.UseVisualStyleBackColor = true;
//
// CLoggerInfo
//
this.CLoggerInfo.Dock = System.Windows.Forms.DockStyle.Fill;
this.CLoggerInfo.Location = new System.Drawing.Point(0, 0);
this.CLoggerInfo.Name = "CLoggerInfo";
this.CLoggerInfo.ReadOnly = true;
this.CLoggerInfo.Size = new System.Drawing.Size(585, 397);
this.CLoggerInfo.TabIndex = 1;
this.CLoggerInfo.Text = "";
//
// Warning
//
this.Warning.Controls.Add(this.CLoggerWarning);
this.Warning.Location = new System.Drawing.Point(4, 22);
this.Warning.Name = "Warning";
this.Warning.Size = new System.Drawing.Size(585, 397);
this.Warning.TabIndex = 4;
this.Warning.Text = "Warning";
this.Warning.UseVisualStyleBackColor = true;
//
// CLoggerWarning
//
this.CLoggerWarning.Dock = System.Windows.Forms.DockStyle.Fill;
this.CLoggerWarning.Location = new System.Drawing.Point(0, 0);
this.CLoggerWarning.Name = "CLoggerWarning";
this.CLoggerWarning.ReadOnly = true;
this.CLoggerWarning.Size = new System.Drawing.Size(585, 397);
this.CLoggerWarning.TabIndex = 1;
this.CLoggerWarning.Text = "";
//
// Error
//
this.Error.Controls.Add(this.CLoggerError);
this.Error.Location = new System.Drawing.Point(4, 22);
this.Error.Name = "Error";
this.Error.Size = new System.Drawing.Size(585, 397);
this.Error.TabIndex = 5;
this.Error.Text = "Error";
this.Error.UseVisualStyleBackColor = true;
//
// CLoggerError
//
this.CLoggerError.Dock = System.Windows.Forms.DockStyle.Fill;
this.CLoggerError.Location = new System.Drawing.Point(0, 0);
this.CLoggerError.Name = "CLoggerError";
this.CLoggerError.ReadOnly = true;
this.CLoggerError.Size = new System.Drawing.Size(585, 397);
this.CLoggerError.TabIndex = 1;
this.CLoggerError.Text = "";
//
// Fatal
//
this.Fatal.Controls.Add(this.CLoggerFatal);
this.Fatal.Location = new System.Drawing.Point(4, 22);
this.Fatal.Name = "Fatal";
this.Fatal.Size = new System.Drawing.Size(585, 397);
this.Fatal.TabIndex = 6;
this.Fatal.Text = "Fatal";
this.Fatal.UseVisualStyleBackColor = true;
//
// CLoggerFatal
//
this.CLoggerFatal.Dock = System.Windows.Forms.DockStyle.Fill;
this.CLoggerFatal.Location = new System.Drawing.Point(0, 0);
this.CLoggerFatal.Name = "CLoggerFatal";
this.CLoggerFatal.ReadOnly = true;
this.CLoggerFatal.Size = new System.Drawing.Size(585, 397);
this.CLoggerFatal.TabIndex = 1;
this.CLoggerFatal.Text = "";
//
// network
//
this.network.Controls.Add(this.NetworkTabs);
this.network.Location = new System.Drawing.Point(4, 22);
this.network.Name = "network";
this.network.Padding = new System.Windows.Forms.Padding(3);
this.network.Size = new System.Drawing.Size(599, 429);
this.network.TabIndex = 6;
this.network.Text = "Network";
this.network.UseVisualStyleBackColor = true;
//
// NetworkTabs
//
this.NetworkTabs.Controls.Add(this.NetworkAllTab);
this.NetworkTabs.Controls.Add(this.NetworkGetTab);
this.NetworkTabs.Controls.Add(this.NetworkPostTab);
this.NetworkTabs.Controls.Add(this.NetworkCommandTab);
this.NetworkTabs.Dock = System.Windows.Forms.DockStyle.Fill;
this.NetworkTabs.Location = new System.Drawing.Point(3, 3);
this.NetworkTabs.Name = "NetworkTabs";
this.NetworkTabs.SelectedIndex = 0;
this.NetworkTabs.Size = new System.Drawing.Size(593, 423);
this.NetworkTabs.TabIndex = 0;
//
// NetworkAllTab
//
this.NetworkAllTab.Controls.Add(this.NetworkAllLogs);
this.NetworkAllTab.Location = new System.Drawing.Point(4, 22);
this.NetworkAllTab.Name = "NetworkAllTab";
this.NetworkAllTab.Padding = new System.Windows.Forms.Padding(3);
this.NetworkAllTab.Size = new System.Drawing.Size(585, 397);
this.NetworkAllTab.TabIndex = 0;
this.NetworkAllTab.Text = "All";
this.NetworkAllTab.UseVisualStyleBackColor = true;
//
// NetworkAllLogs
//
this.NetworkAllLogs.Dock = System.Windows.Forms.DockStyle.Fill;
this.NetworkAllLogs.Location = new System.Drawing.Point(3, 3);
this.NetworkAllLogs.Name = "NetworkAllLogs";
this.NetworkAllLogs.ReadOnly = true;
this.NetworkAllLogs.Size = new System.Drawing.Size(579, 391);
this.NetworkAllLogs.TabIndex = 0;
this.NetworkAllLogs.Text = "";
//
// NetworkGetTab
//
this.NetworkGetTab.Controls.Add(this.NetworkGetLogs);
this.NetworkGetTab.Location = new System.Drawing.Point(4, 22);
this.NetworkGetTab.Name = "NetworkGetTab";
this.NetworkGetTab.Padding = new System.Windows.Forms.Padding(3);
this.NetworkGetTab.Size = new System.Drawing.Size(585, 397);
this.NetworkGetTab.TabIndex = 1;
this.NetworkGetTab.Text = "GET";
this.NetworkGetTab.UseVisualStyleBackColor = true;
//
// NetworkGetLogs
//
this.NetworkGetLogs.Dock = System.Windows.Forms.DockStyle.Fill;
this.NetworkGetLogs.Location = new System.Drawing.Point(3, 3);
this.NetworkGetLogs.Name = "NetworkGetLogs";
this.NetworkGetLogs.ReadOnly = true;
this.NetworkGetLogs.Size = new System.Drawing.Size(579, 391);
this.NetworkGetLogs.TabIndex = 1;
this.NetworkGetLogs.Text = "";
//
// NetworkPostTab
//
this.NetworkPostTab.Controls.Add(this.NetworkPostLogs);
this.NetworkPostTab.Location = new System.Drawing.Point(4, 22);
this.NetworkPostTab.Name = "NetworkPostTab";
this.NetworkPostTab.Size = new System.Drawing.Size(585, 397);
this.NetworkPostTab.TabIndex = 2;
this.NetworkPostTab.Text = "POST";
this.NetworkPostTab.UseVisualStyleBackColor = true;
//
// NetworkPostLogs
//
this.NetworkPostLogs.Dock = System.Windows.Forms.DockStyle.Fill;
this.NetworkPostLogs.Location = new System.Drawing.Point(0, 0);
this.NetworkPostLogs.Name = "NetworkPostLogs";
this.NetworkPostLogs.ReadOnly = true;
this.NetworkPostLogs.Size = new System.Drawing.Size(585, 397);
this.NetworkPostLogs.TabIndex = 1;
this.NetworkPostLogs.Text = "";
//
// NetworkCommandTab
//
this.NetworkCommandTab.Controls.Add(this.NetworkCommandLogs);
this.NetworkCommandTab.Location = new System.Drawing.Point(4, 22);
this.NetworkCommandTab.Name = "NetworkCommandTab";
this.NetworkCommandTab.Padding = new System.Windows.Forms.Padding(3);
this.NetworkCommandTab.Size = new System.Drawing.Size(585, 397);
this.NetworkCommandTab.TabIndex = 3;
this.NetworkCommandTab.Text = "NetCommands";
this.NetworkCommandTab.UseVisualStyleBackColor = true;
//
// NetworkCommandLogs
//
this.NetworkCommandLogs.Dock = System.Windows.Forms.DockStyle.Fill;
this.NetworkCommandLogs.Location = new System.Drawing.Point(3, 3);
this.NetworkCommandLogs.Name = "NetworkCommandLogs";
this.NetworkCommandLogs.ReadOnly = true;
this.NetworkCommandLogs.Size = new System.Drawing.Size(579, 391);
this.NetworkCommandLogs.TabIndex = 2;
this.NetworkCommandLogs.Text = "";
//
// DebugWindow
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -77,14 +470,64 @@ namespace OpenFK
this.Text = "OpenFK - Debug";
this.tabControl1.ResumeLayout(false);
this.logTab.ResumeLayout(false);
this.FileLogsTab.ResumeLayout(false);
this.incoming.ResumeLayout(false);
this.outgoing.ResumeLayout(false);
this.CLogger.ResumeLayout(false);
this.CLoggerTabControl.ResumeLayout(false);
this.All.ResumeLayout(false);
this.Trace.ResumeLayout(false);
this.Debug.ResumeLayout(false);
this.Info.ResumeLayout(false);
this.Warning.ResumeLayout(false);
this.Error.ResumeLayout(false);
this.Fatal.ResumeLayout(false);
this.network.ResumeLayout(false);
this.NetworkTabs.ResumeLayout(false);
this.NetworkAllTab.ResumeLayout(false);
this.NetworkGetTab.ResumeLayout(false);
this.NetworkPostTab.ResumeLayout(false);
this.NetworkCommandTab.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.RichTextBox generalLog;
private System.Windows.Forms.RichTextBox generalLogs;
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage logTab;
private System.Windows.Forms.TabPage FileLogsTab;
private System.Windows.Forms.RichTextBox fileLogs;
private System.Windows.Forms.TabPage incoming;
private System.Windows.Forms.RichTextBox incomingLogs;
private System.Windows.Forms.TabPage outgoing;
private System.Windows.Forms.RichTextBox outgoingLogs;
private System.Windows.Forms.TabPage CLogger;
private System.Windows.Forms.TabControl CLoggerTabControl;
private System.Windows.Forms.TabPage All;
private System.Windows.Forms.RichTextBox CLoggerAll;
private System.Windows.Forms.TabPage Trace;
private System.Windows.Forms.RichTextBox CLoggerTrace;
private System.Windows.Forms.TabPage Debug;
private System.Windows.Forms.RichTextBox CLoggerDebug;
private System.Windows.Forms.TabPage Info;
private System.Windows.Forms.RichTextBox CLoggerInfo;
private System.Windows.Forms.TabPage Warning;
private System.Windows.Forms.RichTextBox CLoggerWarning;
private System.Windows.Forms.TabPage Error;
private System.Windows.Forms.RichTextBox CLoggerError;
private System.Windows.Forms.TabPage Fatal;
private System.Windows.Forms.RichTextBox CLoggerFatal;
private System.Windows.Forms.TabPage network;
private System.Windows.Forms.TabControl NetworkTabs;
private System.Windows.Forms.TabPage NetworkAllTab;
private System.Windows.Forms.TabPage NetworkGetTab;
private System.Windows.Forms.TabPage NetworkPostTab;
private System.Windows.Forms.RichTextBox NetworkAllLogs;
private System.Windows.Forms.RichTextBox NetworkGetLogs;
private System.Windows.Forms.RichTextBox NetworkPostLogs;
private System.Windows.Forms.TabPage NetworkCommandTab;
private System.Windows.Forms.RichTextBox NetworkCommandLogs;
}
}

View File

@ -16,7 +16,30 @@ namespace OpenFK
public DebugWindow()
{
InitializeComponent();
LogManager.debugLogText = generalLog;
LogManager.generalLogs = generalLogs;
LogManager.fileLogs = fileLogs;
LogManager.incomingLogs = incomingLogs;
LogManager.outgoingLogs = outgoingLogs;
LogManager.CLogger = new Dictionary<string, RichTextBox>
{
{ "all", CLoggerAll },
{ "trace", CLoggerTrace },
{ "debug", CLoggerDebug },
{ "info", CLoggerInfo },
{ "warning", CLoggerWarning },
{ "error", CLoggerError },
{ "fatal", CLoggerFatal }
};
LogManager.networkLogs = new Dictionary<string, RichTextBox>
{
{ "All", NetworkAllLogs },
{ "GET", NetworkGetLogs },
{ "POST", NetworkPostLogs },
{ "NetCommand", NetworkCommandLogs }
};
}
}
}

View File

@ -115,7 +115,7 @@ namespace OpenFK
AS2Container.ScaleMode = Settings.Default.ScaleMode;
AS2Container.Movie = Directory.GetCurrentDirectory() + @"\Main.swf"; //Sets Main.swf as the Flash Movie to Play.
AS2Container.Play(); //Plays Main.swf
LogManager.LogToForm("[AS2Container] Main.swf is Loaded");
LogManager.LogGeneral("[AS2Container] Main.swf is Loaded");
AS2Container.FSCommand += new _IShockwaveFlashEvents_FSCommandEventHandler(flashPlayer_FSCommand); //This sets up the FSCommand handler, which CCommunicator likes to use a lot.
try
@ -124,13 +124,13 @@ namespace OpenFK
AS3Container.Quality2 = "High";
AS3Container.ScaleMode = Settings.Default.ScaleMode;
AS3Container.Movie = Directory.GetCurrentDirectory() + @"\MainAS3.swf"; //Sets MainAS3.swf as the Flash Movie to Play.
LogManager.LogToForm("[AS3Container] MainAS3.swf is Loaded");
LogManager.LogGeneral("[AS3Container] MainAS3.swf is Loaded");
AS3Container.FSCommand += new _IShockwaveFlashEvents_FSCommandEventHandler(flashPlayerAS3_FSCommand);
AS3Container.FlashCall += new _IShockwaveFlashEvents_FlashCallEventHandler(flashPlayerAS3_FlashCall);
}
catch
{
LogManager.LogToForm("[AS3Container] AS3 Failed to Load! Potentially an older version.");
LogManager.LogGeneral("[AS3Container] AS3 Failed to Load! Potentially an older version.");
}
//End of Flash initialization
@ -173,7 +173,7 @@ namespace OpenFK
private void flashPlayerAS3_FSCommand(object sender, _IShockwaveFlashEvents_FSCommandEvent e)
{
LogManager.LogToForm("[AS3] [SendMsg] " + e.args);
LogManager.LogIncoming("[AS3] [SendMsg] " + e.args);
if(e.args.Contains("<save_jpeg ")) //Saving jpegs for UG game thumbnails or game over backgrounds.
{
XmlDocument request = new XmlDocument(); //e.args to xml
@ -241,7 +241,7 @@ namespace OpenFK
if (s != usbBittyID) //If it's still the same, it won't repeat the actions
{
usbBittyID = s;
LogManager.LogToForm("[Bitty] USB bitty - " + s);
LogManager.LogGeneral("[Bitty] USB bitty - " + s);
setBitty(s);
}
}
@ -257,7 +257,7 @@ namespace OpenFK
private void flashPlayerAS3_FlashCall(object sender, _IShockwaveFlashEvents_FlashCallEvent e)
{
LogManager.LogToForm("[AS3] [FlashCall] " + e.request);
LogManager.LogIncoming("[AS3] [FlashCall] " + e.request);
if(e.request.Contains("<as3_loaded "))
{
setVar(@"<?xml version=""1.0"" encoding=""UTF - 8""?><commands><as3_loaded id=""1"" path=""MainAS3.swf"" result=""0"" err="""" /></commands>");
@ -285,7 +285,20 @@ namespace OpenFK
void flashPlayer_FSCommand(object sender, _IShockwaveFlashEvents_FSCommandEvent e) //FSCommand Handler
{
LogManager.LogToForm("[AS2] [SendMsg] " + e.args);
if (e.args.Contains("<log")) // logs from modified CLogger
{
var log = new XmlDocument();
log.LoadXml(e.args);
var node = log.SelectSingleNode("/log");
string level = node.Attributes["type"].Value;
string message = node.InnerText;
LogManager.LogLog(message, level);
}
else
{ // Don't log incoming message that are logs to prevent clutter.
LogManager.LogIncoming("[AS2] [SendMsg] " + e.args);
}
//
// XML LOAD COMMANDS
@ -304,7 +317,8 @@ namespace OpenFK
//XML LOADING
filename = xn.Attributes["section"].Value;
foldername = xn.Attributes["name"].Value;
LogManager.LogToForm("[Load] File Requested - " + filename + "/" + foldername);
LogManager.LogFile($"[Load] {foldername}/{filename}");
loadFile(filename, foldername);
//Rich Prescense
@ -394,7 +408,8 @@ namespace OpenFK
{
filename = xn.Attributes["section"].Value;
foldername = xn.Attributes["name"].Value;
LogManager.LogToForm("[Save] File Requested - " + filename + "/" + foldername); //debug output
LogManager.LogFile($"[Save] {foldername}/{filename}");
XDocument args = XDocument.Parse(e.args);
@ -417,7 +432,7 @@ namespace OpenFK
File.WriteAllBytes(Directory.GetCurrentDirectory() + @"\data\" + foldername + @"\" + filename + ".rdf", iso_8859_1.GetBytes(RDFTool.encode(iso_8859_1.GetString(RDFData))));
}
else File.WriteAllText(Directory.GetCurrentDirectory() + @"\data\" + foldername + @"\" + filename + ".xml", output.ToString()); //saves
LogManager.LogToForm("[Save] Successfully saved - " + foldername + "/" + filename); //Debug Output
LogManager.LogFile("[Save] Successfully saved - " + foldername + "/" + filename); //Debug Output
}
}
@ -507,7 +522,7 @@ namespace OpenFK
var updateprocess = Process.Start(updatescript);
}
Application.Exit(); //Closes OpenFK
LogManager.LogToForm("[OpenFK] Radicaclose was called"); //Debug output
LogManager.LogGeneral("[OpenFK] Radicaclose was called"); //Debug output
}
//
@ -560,7 +575,7 @@ namespace OpenFK
//HTTP POST (CRIB SAVING + POSTCARDS)
if (e.args.Contains("<netcommands"))
{
LogManager.LogToForm("[Network] Netcommand called.");
LogManager.LogNetwork("Netcommand called.", "NetCommand");
string tnurl = "";
if(e.args.Contains("<save_level "))
@ -598,7 +613,7 @@ namespace OpenFK
string localVerNum = "1.8";
string fslocalVersion = "";
string fslocalVerNum = "1.0";
LogManager.LogToForm("[Network] [Update] Update Requested");
LogManager.LogNetwork("[Update] Update Requested", "NetCommand");
setVar(@"<progress percent=""0.25"" />");
try
{
@ -608,21 +623,21 @@ namespace OpenFK
}
catch
{
LogManager.LogToForm("[Network] [Update] Update.xml was not found");
LogManager.LogNetwork("[Update] Update.xml was not found", "NetCommand");
}
setVar(@"<progress percent=""25.00"" />");
try
{
LogManager.LogToForm("[Network] [Update] Downloading Update.xml from GitHub");
LogManager.LogNetwork("[Update] Downloading Update.xml from GitHub", "NetCommand");
netStore = XDocument.Parse(Get(@"https://raw.githubusercontent.com/GittyMac/OpenFK/master/update.xml"));
LogManager.LogToForm("[Network] [Update] Update.xml was downloaded");
LogManager.LogNetwork("[Update] Update.xml was downloaded", "NetCommand");
string netVersion = netStore.Root.Attribute("name").Value;
string netVersionNum = netStore.Root.Attribute("version").Value;
string netVersionSize = netStore.Root.Attribute("size").Value;
setVar(@"<progress percent=""50.00"" />");
if (localVersion != netVersion)
{
LogManager.LogToForm("[Network] [Update] An update is needed");
LogManager.LogNetwork("[Update] An update is needed", "NetCommand");
netStore.Save(Directory.GetCurrentDirectory() + @"\update.xml");
setVar(@"<checkupdate result=""2"" reason=""New version of OpenFK found."" version=""2009_07_16_544"" size=""" + netVersionSize + @""" curversion=""" + localVerNum + @""" extversion=""" + netVersionNum + @""" extname=""" + netVersion + @""" />");
}
@ -636,14 +651,14 @@ namespace OpenFK
}
catch
{
LogManager.LogToForm("[Network] [Update] FSGUI Update.xml was not found");
LogManager.LogNetwork("[Update] FSGUI Update.xml was not found", "NetCommand");
}
setVar(@"<progress percent=""75.00"" />");
try
{
LogManager.LogToForm("[Network] [Update] Downloading FSGUI Update.xml from GitHub");
LogManager.LogNetwork("[Update] Downloading FSGUI Update.xml from GitHub", "NetCommand");
fsnetStore = XDocument.Parse(Get(@"https://raw.githubusercontent.com/GittyMac/FunkeySelectorGUI/master/update.xml"));
LogManager.LogToForm("[Network] [Update] FSGUI Update.xml was downloaded");
LogManager.LogNetwork("[Update] FSGUI Update.xml was downloaded", "NetCommand");
string fsnetVersion = fsnetStore.Root.Attribute("name").Value;
string fsnetVersionNum = fsnetStore.Root.Attribute("version").Value;
string fsnetVersionSize = fsnetStore.Root.Attribute("size").Value;
@ -657,9 +672,9 @@ namespace OpenFK
}
catch
{
LogManager.LogToForm("[Network] [Update] Cannot close FSGUI");
LogManager.LogNetwork("[Update] Cannot close FSGUI", "NetCommand");
}
LogManager.LogToForm("[Network] [Update] A FSGUI update is needed");
LogManager.LogNetwork("[Update] A FSGUI update is needed", "NetCommand");
setVar(@"<checkupdate result=""2"" reason=""New version of FSGUI found."" version=""2009_07_16_544"" size=""" + fsnetVersionSize + @""" curversion=""" + fslocalVerNum + @""" extversion=""" + fsnetVersionNum + @""" extname=""" + fsnetVersion + @""" />");
}
else
@ -669,7 +684,7 @@ namespace OpenFK
}
catch
{
LogManager.LogToForm("[Network] [Update] No FSGUI update");
LogManager.LogNetwork("[Update] No FSGUI update", "NetCommand");
setVar(@"<checkupdate result=""1"" reason=""Could not find the FunkeySelectorGUI update!"" />");
}
}
@ -680,7 +695,7 @@ namespace OpenFK
}
catch
{
LogManager.LogToForm("[Network] [Update] No update");
LogManager.LogNetwork("[Update] No update", "NetCommand");
setVar(@"<checkupdate result=""1"" reason=""Could not find the OpenFK update!"" />");
}
}
@ -759,7 +774,7 @@ namespace OpenFK
savepassword = xn.Attributes["savepassword"].Value;
hintq = xn.Attributes["hintq"].Value;
hinta = xn.Attributes["hinta"].Value;
LogManager.LogToForm("[Load] File Requested - system/users");
LogManager.LogFile("[Load] File Requested - system/users");
loadFile("users", "system");
string userString = userData.OuterXml;
string data2send = userString.Replace("</users>", "") + @"<user gname=""" + username + @""" hinta=""" + hinta + @""" hintq=""" + hintq + @""" savepassword=""" + savepassword + @""" password=""" + password + @""" name=""" + username + @""" /></users>";
@ -774,7 +789,7 @@ namespace OpenFK
File.WriteAllBytes(Directory.GetCurrentDirectory() + @"\data\" + "system" + @"\" + "users" + ".rdf", iso_8859_1.GetBytes(RDFTool.encode(iso_8859_1.GetString(RDFData))));
}
else File.WriteAllText(Directory.GetCurrentDirectory() + @"\data\" + "system" + @"\" + "users" + ".xml", data2send.ToString()); //saves
LogManager.LogToForm("[UserAdd] Successfully added user - " + username); //Debug Output
LogManager.LogFile("[UserAdd] Successfully added user - " + username); //Debug Output
}
}
@ -916,7 +931,7 @@ namespace OpenFK
index = @"<commands><load section=""" + file + @""" name=""" + folder + @""" result=""1"" reason=""Error loading file!"" /></commands>"; //I would just let dotNET handle this, but UGLevels needs an error to continue.
}
setVar(index.ToString()); //Sends XML data to the game
LogManager.LogToForm("[Load] Successfully loaded - " + folder + "/" + file); //Debug Output
LogManager.LogFile("[Load] Successfully loaded - " + folder + "/" + file); //Debug Output
}
//
@ -929,7 +944,7 @@ namespace OpenFK
public void setVar(string msg)
{
LogManager.LogToForm("[SetVar/Return] Returned Message - " + msg);
LogManager.LogOutgoing("[SetVar/Return] Returned Message - " + msg);
AS2Container.SetVariable("msg", msg); //Sends message (msg) to the game
}
@ -1002,6 +1017,8 @@ namespace OpenFK
//
public string HTTPPost(string info, string uri)
{
LogManager.LogNetwork($"{uri} {info}", "POST");
var request = (HttpWebRequest)WebRequest.Create(uri);
var data = Encoding.ASCII.GetBytes(info);
request.Method = "POST";
@ -1089,6 +1106,8 @@ namespace OpenFK
//
public string Get(string uri)
{
LogManager.LogNetwork(uri, "GET");
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);

View File

@ -10,20 +10,61 @@ namespace OpenFK.OFK.Common
{
static class LogManager
{
public static RichTextBox debugLogText;
public static void LogToForm(string logElement)
public static RichTextBox generalLogs;
public static RichTextBox fileLogs;
public static RichTextBox incomingLogs;
public static RichTextBox outgoingLogs;
public static Dictionary<string, RichTextBox> CLogger;
public static Dictionary<string, RichTextBox> networkLogs;
private static void AppendLine(RichTextBox richTextBox, string message)
{
if(debugLogText != null)
try
{
try
{
debugLogText.AppendText("\n" + logElement);
}
catch
{
Debug.WriteLine(logElement);
}
richTextBox.AppendText("\n" + message);
}
catch
{
Debug.WriteLine($"[{richTextBox.Name}] {message}");
}
}
public static void LogGeneral(string message)
{
AppendLine(generalLogs, message);
}
public static void LogFile(string message)
{
AppendLine(fileLogs, message);
LogGeneral($"[File] {message}");
}
public static void LogIncoming(string message)
{
AppendLine(incomingLogs, message);
LogGeneral($"[Incoming] {message}");
}
public static void LogOutgoing(string message)
{
AppendLine(outgoingLogs, message);
LogGeneral($"[Outgoing] {message}");
}
public static void LogLog(string message, string level)
{
message = $"[{level}] {message}";
AppendLine(CLogger[level], message);
AppendLine(CLogger["all"], message);
}
public static void LogNetwork(string message, string method)
{
message = $"[{method}] {message}";
AppendLine(networkLogs[method], message);
AppendLine(networkLogs["ALL"], message);
LogGeneral($"[Network] {message}");
}
}
}