Write debug message to a file if DEBUG_LOGS is enabled
(message)
| 53 | return message_numeric >= configured_numeric |
| 54 | |
| 55 | def debug_log(message): |
| 56 | """Write debug message to a file if DEBUG_LOGS is enabled""" |
| 57 | # Check if debug logging is enabled via config |
| 58 | debug_mode = _get_config_value('DEBUG_LOGS', False) |
| 59 | if not debug_mode: |
| 60 | return |
| 61 | |
| 62 | # Get debug log path from config |
| 63 | debug_file = _get_config_value('DEBUG_LOG_PATH', os.path.expanduser("~/mcp_debug.log")) |
| 64 | |
| 65 | # Ensure parent directory exists |
| 66 | Path(debug_file).parent.mkdir(parents=True, exist_ok=True) |
| 67 | |
| 68 | timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S") |
| 69 | with open(debug_file, "a") as f: |
| 70 | f.write(f"[{timestamp}] {message}\n") |
| 71 | f.flush() |
| 72 | |
| 73 | def info_logger(msg): |
| 74 | """Log info message if log level allows""" |
no test coverage detected