fix: prevent header corruption when sexpdata compacts schematic to single line

create_component_instance used line-based insertion which placed new
symbols BEFORE (kicad_sch ...) header when the file was written as
a single line by sexpdata.dumps(). Switch to rfind()-based string
insertion which is format-independent.

Also remove StreamHandler(sys.stdout) from logging — Python logs now
go only to file (~/.kicad-mcp/logs/kicad_interface.log) to avoid
polluting MCP stderr with INFO/DEBUG entries shown as [error].
This commit is contained in:
Tom
2026-03-06 13:17:25 +01:00
parent e7a8234ec4
commit 93ae23dacc
2 changed files with 8 additions and 20 deletions

View File

@@ -26,7 +26,7 @@ log_file = os.path.join(log_dir, "kicad_interface.log")
logging.basicConfig(
level=logging.DEBUG,
format="%(asctime)s [%(levelname)s] %(message)s",
handlers=[logging.FileHandler(log_file), logging.StreamHandler(sys.stdout)],
handlers=[logging.FileHandler(log_file)],
)
logger = logging.getLogger("kicad_interface")