From cf991aa798a70a60d4b9dc3d1209fa5c98d8da88 Mon Sep 17 00:00:00 2001
From: NanderTGA <65074195+NanderTGA@users.noreply.github.com>
Date: Wed, 23 Aug 2023 20:41:37 +0200
Subject: [PATCH 1/2] refactor(logs): make logs shorter and remove unneeded
comments
---
OpenFK/Form1.cs | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/OpenFK/Form1.cs b/OpenFK/Form1.cs
index 3490636..1d3724b 100644
--- a/OpenFK/Form1.cs
+++ b/OpenFK/Form1.cs
@@ -432,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.LogFile("[Save] Successfully saved - " + foldername + "/" + filename); //Debug Output
+ LogManager.LogFile($"[Save] [Success] {foldername}/{filename}");
}
}
@@ -522,7 +522,7 @@ namespace OpenFK
var updateprocess = Process.Start(updatescript);
}
Application.Exit(); //Closes OpenFK
- LogManager.LogGeneral("[OpenFK] Radicaclose was called"); //Debug output
+ LogManager.LogGeneral("[OpenFK] Radicaclose was called");
}
//
@@ -789,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.LogFile("[UserAdd] Successfully added user - " + username); //Debug Output
+ LogManager.LogFile("[UserAdd] [Succes] " + username);
}
}
@@ -931,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.LogFile("[Load] Successfully loaded - " + folder + "/" + file); //Debug Output
+ LogManager.LogFile($"[Load] [Success] {folder}/{file}");
}
//
From b8f137d53bf62ae0244e738fc7910cc3f4b735df Mon Sep 17 00:00:00 2001
From: NanderTGA <65074195+NanderTGA@users.noreply.github.com>
Date: Wed, 23 Aug 2023 23:17:39 +0200
Subject: [PATCH 2/2] feat(logs): add logging for CStaticStorage
---
OpenFK/DebugWindow.Designer.cs | 27 +++++++++++++++++++++++++
OpenFK/DebugWindow.cs | 2 ++
OpenFK/Form1.cs | 35 +++++++++++++++++++++++++++++++++
OpenFK/OFK.Common/LogManager.cs | 20 +++++++++++++++++++
4 files changed, 84 insertions(+)
diff --git a/OpenFK/DebugWindow.Designer.cs b/OpenFK/DebugWindow.Designer.cs
index 8416b4e..1e68971 100644
--- a/OpenFK/DebugWindow.Designer.cs
+++ b/OpenFK/DebugWindow.Designer.cs
@@ -64,6 +64,8 @@ namespace OpenFK
this.NetworkPostLogs = new System.Windows.Forms.RichTextBox();
this.NetworkCommandTab = new System.Windows.Forms.TabPage();
this.NetworkCommandLogs = new System.Windows.Forms.RichTextBox();
+ this.staticStorageTab = new System.Windows.Forms.TabPage();
+ this.staticStorageLogs = new System.Windows.Forms.RichTextBox();
this.tabControl1.SuspendLayout();
this.logTab.SuspendLayout();
this.FileLogsTab.SuspendLayout();
@@ -84,6 +86,7 @@ namespace OpenFK
this.NetworkGetTab.SuspendLayout();
this.NetworkPostTab.SuspendLayout();
this.NetworkCommandTab.SuspendLayout();
+ this.staticStorageTab.SuspendLayout();
this.SuspendLayout();
//
// generalLogs
@@ -104,6 +107,7 @@ namespace OpenFK
this.tabControl1.Controls.Add(this.outgoing);
this.tabControl1.Controls.Add(this.CLogger);
this.tabControl1.Controls.Add(this.network);
+ this.tabControl1.Controls.Add(this.staticStorageTab);
this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabControl1.Location = new System.Drawing.Point(0, 0);
this.tabControl1.Name = "tabControl1";
@@ -460,6 +464,26 @@ namespace OpenFK
this.NetworkCommandLogs.TabIndex = 2;
this.NetworkCommandLogs.Text = "";
//
+ // staticStorageTab
+ //
+ this.staticStorageTab.Controls.Add(this.staticStorageLogs);
+ this.staticStorageTab.Location = new System.Drawing.Point(4, 22);
+ this.staticStorageTab.Name = "staticStorageTab";
+ this.staticStorageTab.Size = new System.Drawing.Size(599, 429);
+ this.staticStorageTab.TabIndex = 7;
+ this.staticStorageTab.Text = "CStaticStorage";
+ this.staticStorageTab.UseVisualStyleBackColor = true;
+ //
+ // staticStorageLogs
+ //
+ this.staticStorageLogs.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.staticStorageLogs.Location = new System.Drawing.Point(0, 0);
+ this.staticStorageLogs.Name = "staticStorageLogs";
+ this.staticStorageLogs.ReadOnly = true;
+ this.staticStorageLogs.Size = new System.Drawing.Size(599, 429);
+ this.staticStorageLogs.TabIndex = 0;
+ this.staticStorageLogs.Text = "";
+ //
// DebugWindow
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -488,6 +512,7 @@ namespace OpenFK
this.NetworkGetTab.ResumeLayout(false);
this.NetworkPostTab.ResumeLayout(false);
this.NetworkCommandTab.ResumeLayout(false);
+ this.staticStorageTab.ResumeLayout(false);
this.ResumeLayout(false);
}
@@ -529,5 +554,7 @@ namespace OpenFK
private System.Windows.Forms.RichTextBox NetworkPostLogs;
private System.Windows.Forms.TabPage NetworkCommandTab;
private System.Windows.Forms.RichTextBox NetworkCommandLogs;
+ private System.Windows.Forms.TabPage staticStorageTab;
+ private System.Windows.Forms.RichTextBox staticStorageLogs;
}
}
\ No newline at end of file
diff --git a/OpenFK/DebugWindow.cs b/OpenFK/DebugWindow.cs
index cabc792..4e8ad8e 100644
--- a/OpenFK/DebugWindow.cs
+++ b/OpenFK/DebugWindow.cs
@@ -40,6 +40,8 @@ namespace OpenFK
{ "POST", NetworkPostLogs },
{ "NetCommand", NetworkCommandLogs }
};
+
+ LogManager.staticStorageLogs = staticStorageLogs;
}
}
}
diff --git a/OpenFK/Form1.cs b/OpenFK/Form1.cs
index 1d3724b..87f6119 100644
--- a/OpenFK/Form1.cs
+++ b/OpenFK/Form1.cs
@@ -285,6 +285,9 @@ namespace OpenFK
void flashPlayer_FSCommand(object sender, _IShockwaveFlashEvents_FSCommandEvent e) //FSCommand Handler
{
+ // We put these here because these use a different xml scheme and to prevent clutter in the general logs.
+ // It is also important to return, since only we call this and know to not put anything else in it to prevent bugs due to bad code below.
+
if (e.args.Contains(" CLogger;
public static Dictionary networkLogs;
+ public static RichTextBox staticStorageLogs;
private static void AppendLine(RichTextBox richTextBox, string message)
{
@@ -66,5 +67,24 @@ namespace OpenFK.OFK.Common
AppendLine(networkLogs["All"], message);
LogGeneral($"[Network] {message}");
}
+
+ //TODO: implement table view to keep track of values like the localstorage viewer in devtools
+ public static void LogStaticStorageSet(string key, string oldValue, string newValue)
+ {
+ string message = $"[Set] {key} = {oldValue} --> {newValue}";
+ AppendLine(staticStorageLogs, message);
+ }
+
+ public static void LogStaticStorageGet(string key, string value, string defaultValue)
+ {
+ string message = $"[Get] {key} = {value} || {defaultValue}";
+ AppendLine(staticStorageLogs, message);
+ }
+
+ public static void LogStaticStorageDelete(string key, string oldValue)
+ {
+ string message = $"[Delete] {key} = {oldValue}";
+ AppendLine(staticStorageLogs, message);
+ }
}
}