make debug log hook a setting

This commit is contained in:
JohnCorby 2022-02-10 05:35:23 -08:00
parent cb00fafa1c
commit 1885ab201d
3 changed files with 17 additions and 10 deletions

View File

@ -66,16 +66,19 @@ namespace QSB
DebugSettings = Helper.Storage.Load<DebugSettings>("debugsettings.json") ?? new DebugSettings();
Application.logMessageReceived += (condition, stackTrace, logType) =>
DebugLog.DebugWrite($"[Debug] {condition} {stackTrace}", logType switch
{
LogType.Error => MessageType.Error,
LogType.Assert => MessageType.Error,
LogType.Warning => MessageType.Warning,
LogType.Log => MessageType.Message,
LogType.Exception => MessageType.Error,
_ => throw new ArgumentOutOfRangeException(nameof(logType), logType, null)
});
if (DebugSettings.HookDebugLogs)
{
Application.logMessageReceived += (condition, stackTrace, logType) =>
DebugLog.DebugWrite($"[Debug] {condition} {stackTrace}", logType switch
{
LogType.Error => MessageType.Error,
LogType.Assert => MessageType.Error,
LogType.Warning => MessageType.Warning,
LogType.Log => MessageType.Message,
LogType.Exception => MessageType.Error,
_ => throw new ArgumentOutOfRangeException(nameof(logType), logType, null)
});
}
InitializeAssemblies();

View File

@ -13,6 +13,9 @@ namespace QSB.Utility
[JsonProperty("playerIdInLogs")]
public bool PlayerIdInLogs;
[JsonProperty("hookDebugLogs")]
public bool HookDebugLogs;
[JsonProperty("debugMode")]
public bool DebugMode;

View File

@ -2,6 +2,7 @@
"useKcpTransport": false,
"dumpWorldObjects": false,
"playerIdInLogs": false,
"hookDebugLogs": false,
"debugMode": false,
"drawGui": false,
"drawLines": false,