From eb3c774d47cbe53bb097236608ea1552978a76ec Mon Sep 17 00:00:00 2001 From: NanderTGA <65074195+NanderTGA@users.noreply.github.com> Date: Sat, 12 Aug 2023 23:56:04 +0200 Subject: [PATCH] feat: greatly improve debugging --- OpenFK/DebugWindow.Designer.cs | 465 +++++++++++++++++++++++++++++++- OpenFK/DebugWindow.cs | 25 +- OpenFK/Form1.cs | 75 ++++-- OpenFK/OFK.Common/LogManager.cs | 63 ++++- 4 files changed, 577 insertions(+), 51 deletions(-) diff --git a/OpenFK/DebugWindow.Designer.cs b/OpenFK/DebugWindow.Designer.cs index c111639..8416b4e 100644 --- a/OpenFK/DebugWindow.Designer.cs +++ b/OpenFK/DebugWindow.Designer.cs @@ -29,26 +29,81 @@ namespace OpenFK /// 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; } } \ No newline at end of file diff --git a/OpenFK/DebugWindow.cs b/OpenFK/DebugWindow.cs index b8a2326..cabc792 100644 --- a/OpenFK/DebugWindow.cs +++ b/OpenFK/DebugWindow.cs @@ -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 + { + { "all", CLoggerAll }, + { "trace", CLoggerTrace }, + { "debug", CLoggerDebug }, + { "info", CLoggerInfo }, + { "warning", CLoggerWarning }, + { "error", CLoggerError }, + { "fatal", CLoggerFatal } + }; + + LogManager.networkLogs = new Dictionary + { + { "All", NetworkAllLogs }, + { "GET", NetworkGetLogs }, + { "POST", NetworkPostLogs }, + { "NetCommand", NetworkCommandLogs } + }; } } } diff --git a/OpenFK/Form1.cs b/OpenFK/Form1.cs index be7bb62..3490636 100644 --- a/OpenFK/Form1.cs +++ b/OpenFK/Form1.cs @@ -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(""); @@ -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(""); 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(@""); 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(@""); 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(@""); } @@ -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(@""); 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(@""); } else @@ -669,7 +684,7 @@ namespace OpenFK } catch { - LogManager.LogToForm("[Network] [Update] No FSGUI update"); + LogManager.LogNetwork("[Update] No FSGUI update", "NetCommand"); setVar(@""); } } @@ -680,7 +695,7 @@ namespace OpenFK } catch { - LogManager.LogToForm("[Network] [Update] No update"); + LogManager.LogNetwork("[Update] No update", "NetCommand"); setVar(@""); } } @@ -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("", "") + @""; @@ -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 = @""; //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); diff --git a/OpenFK/OFK.Common/LogManager.cs b/OpenFK/OFK.Common/LogManager.cs index b15f00f..0638874 100644 --- a/OpenFK/OFK.Common/LogManager.cs +++ b/OpenFK/OFK.Common/LogManager.cs @@ -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 CLogger; + public static Dictionary 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}"); } } }