-
Notifications
You must be signed in to change notification settings - Fork 79
fix: Map 'info' log type to Unity's 'Log' type for console log retrieval #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Map 'info' log type to Unity's 'Log' type for console log retrieval #40
Conversation
The get_console_logs tool was unable to retrieve info logs because MCP's "info" parameter didn't match Unity's internal "Log" type string. Added mapping logic to convert "info" to "Log" before filtering log entries. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Your cubic subscription is currently inactive. Please reactivate your subscription to receive AI reviews and use cubic. |
📝 Walkthrough""" WalkthroughThe method responsible for returning logs as JSON was updated to normalize the input log type string using a static dictionary that maps external MCP log types (e.g., "info") to Unity's internal log types (e.g., "Log"). This mapping occurs once before filtering to ensure consistent log type comparisons. Changes
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move log type mapping logic outside the loop to avoid repeated processing. Added static Dictionary for MCP-to-Unity log type mappings with case-insensitive comparison. This improves performance and provides better extensibility for future log type mappings. Addresses CodeRabbit review feedback for performance optimization. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
interesting solution but this only accepts "info" requests |
Per PR review feedback, expanded the log type mapping to handle multi-value mappings. The "error" filter now returns all error-related log types. We found that filtering by "error" was not comprehensive enough for development purposes - Exception and Assert logs are also error conditions that developers need to see. Changes: - Changed LogTypeMapping from Dictionary<string, string> to Dictionary<string, HashSet<string>> to support 1-to-many mappings - Added "error" → {"Error", "Exception", "Assert"} mapping - Updated GetAllLogsAsJson filtering logic to use HashSet.Contains() This ensures developers can see all error-related logs when filtering by "error" type, making debugging more effective. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
@CoderGamester Thank you for the review! After reviewing the code and considering MCP's standard naming conventions, I realized:
I've updated the implementation to support multi-value mappings. The
This makes the tool more useful for developers since all error conditions are captured with a single filter. Changes made:
The implementation maintains backward compatibility while providing more comprehensive error filtering. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Summary
• Fix info log type mapping issue in ConsoleLogsService where MCP's "info" parameter didn't match Unity's "Log" type
• Add mapping logic to convert "info" to "Log" before filtering log entries in GetAllLogsAsJson method
Environment Details
get_console_logs
withlogType: "info"
parameterProblem Description
The
get_console_logs
MCP tool was unable to retrieve info-level logs when using the"info"
logType parameter. This occurred because:Debug.Log()
messages are stored asLogType.Log
(string:"Log"
)logType: "info"
"info" \!= "Log"
caused info logs to be filtered outReproduction Steps
Root Cause
In
ConsoleLogsService.cs
line 83, the filtering logic:Would compare
"info"
(MCP parameter) with"Log"
(Unity's LogType.Log.ToString()), causing a mismatch.Solution
Added type mapping logic before filtering:
Test Plan
send_console_log
tool withtype: "info"
get_console_logs
tool withlogType: "info"
Impact
This fix enables proper info log retrieval through MCP tools, making debugging and monitoring more effective for MCP Unity users.
🤖 Generated with Claude Code
Summary by CodeRabbit