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
main
David Sarno 2025-08-10 20:12:45 -07:00
parent a40db48132
commit dc6171dfe6
1 changed files with 13 additions and 1 deletions

View File

@ -267,7 +267,8 @@ namespace UnityMcpBridge.Editor.Tools
// --- Filtering --- // --- Filtering ---
// Prefer classifying severity from message/stacktrace; fallback to mode bits if needed // Prefer classifying severity from message/stacktrace; fallback to mode bits if needed
LogType unityType = InferTypeFromMessage(message); LogType unityType = InferTypeFromMessage(message);
if (unityType == LogType.Log) bool isExplicitDebugLog = IsExplicitDebugLog(message);
if (!isExplicitDebugLog && unityType == LogType.Log)
{ {
unityType = GetLogTypeFromMode(mode); unityType = GetLogTypeFromMode(mode);
} }
@ -422,6 +423,8 @@ namespace UnityMcpBridge.Editor.Tools
return LogType.Error; return LogType.Error;
if (fullMessage.IndexOf("LogWarning", StringComparison.OrdinalIgnoreCase) >= 0) if (fullMessage.IndexOf("LogWarning", StringComparison.OrdinalIgnoreCase) >= 0)
return LogType.Warning; return LogType.Warning;
if (IsExplicitDebugLog(fullMessage))
return LogType.Log;
// Exceptions often include the word "Exception" in the first lines // Exceptions often include the word "Exception" in the first lines
if (fullMessage.IndexOf("Exception", StringComparison.OrdinalIgnoreCase) >= 0) if (fullMessage.IndexOf("Exception", StringComparison.OrdinalIgnoreCase) >= 0)
@ -434,6 +437,15 @@ namespace UnityMcpBridge.Editor.Tools
return LogType.Log; 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;
}
/// <summary> /// <summary>
/// Applies the "one level lower" remapping for filtering, like the old version. /// Applies the "one level lower" remapping for filtering, like the old version.
/// This ensures compatibility with the filtering logic that expects remapped types. /// This ensures compatibility with the filtering logic that expects remapped types.