From 4c0eb33998bce0b7352a4a8d1fb68acf46b76368 Mon Sep 17 00:00:00 2001 From: zanjonke Date: Wed, 1 Jul 2026 13:47:13 +0200 Subject: [PATCH] fix: suppress duplicate error output before logging setup --- plain2code_logger.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plain2code_logger.py b/plain2code_logger.py index e3980606..f62aed6b 100644 --- a/plain2code_logger.py +++ b/plain2code_logger.py @@ -9,6 +9,13 @@ LOGGER_NAME = "codeplain" +# Attach a NullHandler so that log records emitted before setup_logging() configures +# the real handlers (e.g. during --dry-run, --status, --full-plain, or early parse +# errors) are not printed to stderr by logging.lastResort. Without this, console.error() +# / console.warning() — which both log the message and print it via rich — would show the +# same message twice: once in plain text (from lastResort) and once styled (from rich). +logging.getLogger(LOGGER_NAME).addHandler(logging.NullHandler()) + class IndentedFormatter(logging.Formatter): def format(self, record):