Skip to content

Commit dc6171d

Browse files
committed
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
1 parent a40db48 commit dc6171d

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

UnityMcpBridge/Editor/Tools/ReadConsole.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,8 @@ bool includeStacktrace
267267
// --- Filtering ---
268268
// Prefer classifying severity from message/stacktrace; fallback to mode bits if needed
269269
LogType unityType = InferTypeFromMessage(message);
270-
if (unityType == LogType.Log)
270+
bool isExplicitDebugLog = IsExplicitDebugLog(message);
271+
if (!isExplicitDebugLog && unityType == LogType.Log)
271272
{
272273
unityType = GetLogTypeFromMode(mode);
273274
}
@@ -422,6 +423,8 @@ private static LogType InferTypeFromMessage(string fullMessage)
422423
return LogType.Error;
423424
if (fullMessage.IndexOf("LogWarning", StringComparison.OrdinalIgnoreCase) >= 0)
424425
return LogType.Warning;
426+
if (IsExplicitDebugLog(fullMessage))
427+
return LogType.Log;
425428

426429
// Exceptions often include the word "Exception" in the first lines
427430
if (fullMessage.IndexOf("Exception", StringComparison.OrdinalIgnoreCase) >= 0)
@@ -434,6 +437,15 @@ private static LogType InferTypeFromMessage(string fullMessage)
434437
return LogType.Log;
435438
}
436439

440+
private static bool IsExplicitDebugLog(string fullMessage)
441+
{
442+
// Detect explicit Debug.Log in the stacktrace/message to lock type to Log
443+
if (string.IsNullOrEmpty(fullMessage)) return false;
444+
if (fullMessage.IndexOf("Debug:Log (", StringComparison.OrdinalIgnoreCase) >= 0) return true;
445+
if (fullMessage.IndexOf("UnityEngine.Debug:Log (", StringComparison.OrdinalIgnoreCase) >= 0) return true;
446+
return false;
447+
}
448+
437449
/// <summary>
438450
/// Applies the "one level lower" remapping for filtering, like the old version.
439451
/// This ensures compatibility with the filtering logic that expects remapped types.

0 commit comments

Comments
 (0)