Skip to content

Commit 6b488ed

Browse files
committed
Add version and last text logging
1 parent 098b294 commit 6b488ed

File tree

4 files changed

+27
-5
lines changed

4 files changed

+27
-5
lines changed

Assets.Scripts.Core.History/TextHistory.cs

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ public class TextHistory
2020

2121
private HistoryLine last;
2222

23+
private static string lastEN = "<No line outputted yet>";
24+
public static string GetLastEN() => lastEN;
25+
2326
private TextMeshPro textMeasurer;
2427

2528
public int EnglishLineCount { get; private set; } = 0;
@@ -60,6 +63,7 @@ private string FormatName(string name)
6063

6164
public void RegisterLine(string english, string japanese, string nameen, string namejp)
6265
{
66+
lastEN = english ?? "<Null english line>";
6367
english = sizeTagRegex.Replace(english, "");
6468
japanese = sizeTagRegex.Replace(japanese, "");
6569
if (english.StartsWith("\n"))

Assets.Scripts.Core/GameSystem.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public GameState GameState
221221

222222
private void Initialize()
223223
{
224-
Logger.Log("GameSystem: Starting GameSystem");
224+
Logger.Log($"GameSystem: Starting GameSystem - DLL Version: {MODUtility.InformationalVersion()}");
225225
IsInitialized = true;
226226
AssetManager = new AssetManager();
227227
AudioController = new AudioController();

MOD.Scripts.Core/MODLogger.cs

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using MOD.Scripts.UI;
1+
using Assets.Scripts.Core.History;
2+
using MOD.Scripts.UI;
23
using System;
34
using System.Collections.Generic;
45
using System.IO;
@@ -55,15 +56,15 @@ private static StreamWriter Writer()
5556
if (_currentLogFile == null)
5657
{
5758
var logFile = GetLogFilePath();
58-
Debug.Log($"[MOD] Begin Logging to {logFile}");
59+
Debug.Log($"[MOD] Begin Logging to {logFile} - DLL Version: {MODUtility.InformationalVersion()} - Last Text: [{TextHistory.GetLastEN().Trim()}]");
5960
_currentLogFile = new StreamWriter(logFile.Open(FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite));
6061
_currentLogFile.WriteLine($"---- Logging started at [{DateTime.Now}|{Time.realtimeSinceStartup}] ----");
6162
}
6263

6364
return _currentLogFile;
6465
}
6566

66-
public static void Log(string message, bool stackTrace)
67+
public static void Log(string message, bool withContext)
6768
{
6869
try
6970
{
@@ -74,8 +75,10 @@ public static void Log(string message, bool stackTrace)
7475
sb.Append(message);
7576

7677
// Optionally, log a stack trace
77-
if (stackTrace)
78+
if (withContext)
7879
{
80+
sb.Append("\n");
81+
sb.Append($"Last text: [{TextHistory.GetLastEN().Trim()}]");
7982
sb.Append("\n");
8083
sb.Append(StackTraceUtility.ExtractStackTrace());
8184
}

MOD.Scripts.Core/MODUtility.cs

+15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
using System;
12
using System.Collections.Generic;
23
using System.Linq;
4+
using System.Reflection;
35
using System.Runtime.InteropServices;
46
using System.Text;
57
using Assets.Scripts.Core.Buriko;
@@ -108,4 +110,17 @@ public static Platform GetPlatform()
108110
}
109111

110112
public static string StripTabs(string s) => s.Replace("\t", "");
113+
114+
public static string InformationalVersion()
115+
{
116+
try
117+
{
118+
return Assembly.GetExecutingAssembly().GetName().Version.ToString();
119+
}
120+
catch(Exception e)
121+
{
122+
Debug.Log(e);
123+
return "Unknown Version";
124+
}
125+
}
111126
}

0 commit comments

Comments
 (0)