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

View File

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

View File

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