From eda66a2334fb699e6dc7ff91699de0b39c905fc1 Mon Sep 17 00:00:00 2001 From: glax Date: Sat, 2 Nov 2024 23:32:39 +0100 Subject: [PATCH] Add debug output --- CS2GSI/CS2GSI.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CS2GSI/CS2GSI.cs b/CS2GSI/CS2GSI.cs index c3eff4a..a0d4adc 100644 --- a/CS2GSI/CS2GSI.cs +++ b/CS2GSI/CS2GSI.cs @@ -1,5 +1,6 @@ using CS2GSI.GameState; using Microsoft.Extensions.Logging; +using Newtonsoft.Json; using Newtonsoft.Json.Linq; namespace CS2GSI; @@ -36,6 +37,13 @@ public class CS2GSI JObject jsonObject = JObject.Parse(messageJson); CS2GameState newState = CS2GameState.ParseFromJObject(jsonObject); this._logger?.Log(LogLevel.Debug, $"{Resources.Received_State}:\n{newState.ToString()}"); +#if DEBUG + long time = DateTime.Now.ToFileTime(); + Directory.CreateDirectory("states"); + File.WriteAllText(Path.Join("states", $"{time}.json"), JsonConvert.SerializeObject(newState, Formatting.Indented, new Newtonsoft.Json.Converters.StringEnumConverter())); + Directory.CreateDirectory("messages"); + File.WriteAllText(Path.Join("messages", $"{time}.json"), messageJson); +#endif if (_lastLocalGameState is not null && _allGameStates.Count > 0) {