mirror of
https://github.com/hanzoai/mcp.git
synced 2026-10-29 02:55:49 +00:00
3.3 KiB
3.3 KiB
Logging Conversion Summary
Overview
Converted all print() statements in the hanzo_mcp codebase to use proper logging to ensure they respect the logging configuration and won't interfere with stdio transport.
Files Modified
Core Server Files
-
hanzo_mcp/cli.py
- Converted signal handler messages
- Converted error messages
- Converted installation success messages
- Added logger instantiation where needed
-
hanzo_mcp/server.py
- Added logging import
- Converted shutdown messages
- Converted session cleanup messages
-
hanzo_mcp/dev_server.py
- Added logging import
- Converted file watcher messages
- Converted server status messages
- Converted restart messages
Tools Package
-
hanzo_mcp/tools/__init__.py
- Converted project detection message
-
hanzo_mcp/tools/vector/__init__.py
- Converted project detection message
- Converted missing dependency warning
-
hanzo_mcp/tools/vector/project_manager.py
- Converted error message for project search failures
-
hanzo_mcp/tools/vector/infinity_store.py
- Converted AST search error messages
- Converted file reference error messages
- Converted vector store clearing error messages
-
hanzo_mcp/tools/vector/ast_analyzer.py
- Converted parser initialization warning
- Converted file analysis error messages
- Converted syntax error messages
Configuration Files
-
hanzo_mcp/config/settings.py
- Converted config loading warnings
-
hanzo_mcp/cli_enhanced.py
- Added logging import
- Converted tool listing output
- Converted configuration save messages
Shell Tools
-
hanzo_mcp/tools/shell/command_executor.py
- Converted debug messages to use logger.debug()
-
hanzo_mcp/tools/shell/bash_session_executor.py
- Converted debug messages to use logger.debug()
Files NOT Modified
Test Files
- Test files (test_*.py) were left unchanged as they commonly use print() for test output and debugging
Script Files
- Scripts in the scripts/ directory were left unchanged as they are standalone utilities that should provide direct console output
Documentation Examples
- Print statements in docstrings and examples were left unchanged as they are not executable code
Key Changes
- Logging Import: Added
import loggingwhere needed - Logger Creation: Used
logger = logging.getLogger(__name__)for module-specific loggers - Log Levels:
- Used
logger.info()for informational messages - Used
logger.error()for error messages - Used
logger.warning()for warnings - Used
logger.debug()for debug messages
- Used
- Conditional Logging: Maintained conditions for stdio transport to avoid interfering with the protocol
Benefits
- Protocol Safety: Logging respects the stdio transport protocol and won't corrupt it
- Configurability: Log levels can be controlled via configuration
- Consistency: All server components now use the same logging system
- Debugging: Debug messages can be enabled/disabled via log level settings
Testing Recommendations
- Test with stdio transport to ensure no output corruption
- Test with SSE transport to verify logging works correctly
- Verify log level configuration works as expected
- Check that debug messages only appear when debug level is enabled