From dc6171dfe653aeb91e78f947100016cf835ad218 Mon Sep 17 00:00:00 2001 From: David Sarno Date: Sun, 10 Aug 2025 20:12:45 -0700 Subject: [PATCH] ReadConsole: lock Debug.Log classification to Log; avoid bit-based fallback when stacktrace shows Debug:Log - Detect explicit Debug.Log in stacktrace (UnityEngine.Debug:Log) - Do not downgrade/upgrade to Warning via mode bits for editor-originated logs - Keeps informational setup lines (e.g., MCP registration, bridge start) as Log --- UnityMcpBridge/Editor/Tools/ReadConsole.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/UnityMcpBridge/Editor/Tools/ReadConsole.cs b/UnityMcpBridge/Editor/Tools/ReadConsole.cs index eca81b8..12350d2 100644 --- a/UnityMcpBridge/Editor/Tools/ReadConsole.cs +++ b/UnityMcpBridge/Editor/Tools/ReadConsole.cs @@ -267,7 +267,8 @@ namespace UnityMcpBridge.Editor.Tools // --- Filtering --- // Prefer classifying severity from message/stacktrace; fallback to mode bits if needed LogType unityType = InferTypeFromMessage(message); - if (unityType == LogType.Log) + bool isExplicitDebugLog = IsExplicitDebugLog(message); + if (!isExplicitDebugLog && unityType == LogType.Log) { unityType = GetLogTypeFromMode(mode); } @@ -422,6 +423,8 @@ namespace UnityMcpBridge.Editor.Tools return LogType.Error; if (fullMessage.IndexOf("LogWarning", StringComparison.OrdinalIgnoreCase) >= 0) return LogType.Warning; + if (IsExplicitDebugLog(fullMessage)) + return LogType.Log; // Exceptions often include the word "Exception" in the first lines if (fullMessage.IndexOf("Exception", StringComparison.OrdinalIgnoreCase) >= 0) @@ -434,6 +437,15 @@ namespace UnityMcpBridge.Editor.Tools return LogType.Log; } + private static bool IsExplicitDebugLog(string fullMessage) + { + // Detect explicit Debug.Log in the stacktrace/message to lock type to Log + if (string.IsNullOrEmpty(fullMessage)) return false; + if (fullMessage.IndexOf("Debug:Log (", StringComparison.OrdinalIgnoreCase) >= 0) return true; + if (fullMessage.IndexOf("UnityEngine.Debug:Log (", StringComparison.OrdinalIgnoreCase) >= 0) return true; + return false; + } + /// /// Applies the "one level lower" remapping for filtering, like the old version. /// This ensures compatibility with the filtering logic that expects remapped types.