From 921e087351254457f4f8d4808b4ce45dbd121b01 Mon Sep 17 00:00:00 2001 From: Lama Date: Sat, 22 Mar 2025 09:23:22 -0400 Subject: [PATCH] logging docs cleanup --- docs/configuration.md | 28 +++++----------------------- docs/troubleshooting.md | 8 -------- kicad_mcp/tools/export_tools.py | 22 ++-------------------- kicad_mcp/utils/env.py | 6 ++---- main.py | 2 +- 5 files changed, 10 insertions(+), 56 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 275a665..3231d7e 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -29,15 +29,6 @@ These settings control how the server locates KiCad: |---------------------|-------------|---------------|---------| | `KICAD_APP_PATH` | Path to the KiCad application | `/Applications/KiCad/KiCad.app` (macOS)
`C:\Program Files\KiCad` (Windows)
`/usr/share/kicad` (Linux) | `/Applications/KiCad7/KiCad.app` | -### Logging Configuration - -These settings control server logging behavior: - -| Environment Variable | Description | Default Value | Example | -|---------------------|-------------|---------------|---------| -| `LOG_LEVEL` | Sets logging verbosity | `INFO` | `DEBUG`, `INFO`, `WARNING`, `ERROR` | -| `LOG_DIR` | Directory for log files | `logs` | `~/.kicad_mcp/logs` | - ## Using a .env File (Recommended) The recommended way to configure the server is by creating a `.env` file in the project root: @@ -69,10 +60,6 @@ The recommended way to configure the server is by creating a `.env` file in the # KICAD_APP_PATH=C:\Program Files\KiCad # Linux: # KICAD_APP_PATH=/usr/share/kicad - - # Logging configuration - LOG_LEVEL=INFO - LOG_DIR=logs ``` ## Directory Structure and Project Discovery @@ -147,7 +134,7 @@ You can also set environment variables directly in the client configuration: ], "env": { "KICAD_SEARCH_PATHS": "/custom/path1,/custom/path2", - "LOG_LEVEL": "DEBUG" + "KICAD_APP_PATH": "/custom/path" } } } @@ -222,19 +209,14 @@ KICAD_APP_PATH=/opt/kicad If you're having configuration problems: -1. Run the server with debug logging: +1. Run the server: ```bash - LOG_LEVEL=DEBUG python main.py + python main.py ``` -2. Check the logs for configuration-related messages: - ```bash - cat logs/kicad_mcp_*.log | grep "config" - ``` - -3. Verify environment variables are being loaded: +2. Verify environment variables are being loaded: ```bash python -c "import os; print(os.environ.get('KICAD_SEARCH_PATHS', 'Not set'))" ``` -4. Try absolute paths to eliminate path resolution issues +3. Try absolute paths to eliminate path resolution issues diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 9f54652..0ffbc2d 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -194,14 +194,6 @@ To diagnose issues, check the server logs: %APPDATA%\Claude\Logs\ ``` -### Enabling Debug Logging - -For more detailed logs, set the logging level to DEBUG in your `.env` file: - -``` -LOG_LEVEL=DEBUG -``` - ## DRC and Export Feature Issues ### DRC Checks Failing diff --git a/kicad_mcp/tools/export_tools.py b/kicad_mcp/tools/export_tools.py index cd7c340..e70ead7 100644 --- a/kicad_mcp/tools/export_tools.py +++ b/kicad_mcp/tools/export_tools.py @@ -105,25 +105,7 @@ def register_export_tools(mcp: FastMCP) -> None: await ctx.report_progress(10, 100) ctx.info(f"Generating thumbnail for {os.path.basename(pcb_file)}") - # Method 1: Try to use pcbnew Python module if available - if kicad_modules_available: - try: - thumbnail = await generate_thumbnail_with_pcbnew(pcb_file, ctx) - if thumbnail: - # Cache the result if possible - if hasattr(app_context, 'cache'): - app_context.cache[cache_key] = thumbnail - return thumbnail - - # If pcbnew method failed, log it but continue to try alternative method - print("Failed to generate thumbnail with pcbnew, trying CLI method") - except Exception as e: - print(f"Error using pcbnew for thumbnail: {str(e)}", exc_info=True) - ctx.info(f"Error with pcbnew method, trying alternative approach") - else: - print("KiCad Python modules not available, trying CLI method") - - # Method 2: Try to use command-line tools + # Try to use command-line tools try: thumbnail = await generate_thumbnail_with_cli(pcb_file, ctx) if thumbnail: @@ -135,7 +117,7 @@ def register_export_tools(mcp: FastMCP) -> None: print(f"Error using CLI for thumbnail: {str(e)}", exc_info=True) ctx.info(f"Error generating thumbnail with CLI method") - # If all methods fail, inform the user + # If it fails, inform the user ctx.info("Could not generate thumbnail for PCB - all methods failed") return None diff --git a/kicad_mcp/utils/env.py b/kicad_mcp/utils/env.py index 54ff6af..c492dff 100644 --- a/kicad_mcp/utils/env.py +++ b/kicad_mcp/utils/env.py @@ -2,9 +2,7 @@ Environment variable handling for KiCad MCP Server. """ import os -import logging -from pathlib import Path -from typing import Dict, Any, Optional +from typing import Dict, Optional def load_dotenv(env_file: str = ".env") -> Dict[str, str]: """Load environment variables from .env file. @@ -54,7 +52,7 @@ def load_dotenv(env_file: str = ".env") -> Dict[str, str]: env_vars[key] = value except Exception as e: - logging.warning(f"Error loading .env file: {str(e)}") + print(f"Error loading .env file: {str(e)}") return env_vars diff --git a/main.py b/main.py index 55efb21..a5e9336 100644 --- a/main.py +++ b/main.py @@ -17,7 +17,7 @@ if __name__ == "__main__": try: print("Starting KiCad MCP server") - # Log search paths from config + # Print search paths from config print(f"Using KiCad user directory: {KICAD_USER_DIR}") if ADDITIONAL_SEARCH_PATHS: print(f"Additional search paths: {', '.join(ADDITIONAL_SEARCH_PATHS)}")