From 391d88205f72434bf84f317e9452998bf10cebc7 Mon Sep 17 00:00:00 2001 From: "cpfiffer (aider)" Date: Tue, 13 May 2025 10:13:14 -0700 Subject: [PATCH] fix: Use RichHandler for logs and fix newline --- src/comind/comind.py | 6 +++--- src/comind/logging_config.py | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/comind/comind.py b/src/comind/comind.py index 24971a2..a06ed75 100644 --- a/src/comind/comind.py +++ b/src/comind/comind.py @@ -312,7 +312,7 @@ class Conceptualizer(Comind): log_lines.append(f"[bold magenta]Strength:[/bold magenta] {concept_strength}") log_message = "\n".join(log_lines) - self.logger.info(f"\n{log_message}") + self.logger.info(log_message) # Create printout string printout = f""" @@ -437,7 +437,7 @@ class Feeler(Comind): log_lines.append(f"[bold magenta]Strength:[/bold magenta] {emotion_strength}") log_message = "\n".join(log_lines) - self.logger.info(f"\n{log_message}") + self.logger.info(log_message) # Create printout string printout = f""" @@ -571,7 +571,7 @@ class Thinker(Comind): log_lines.append(f"[bold orange]Alternatives:[/bold orange] {alt_str}") log_message = "\n".join(log_lines) - self.logger.info(f"\n{log_message}") + self.logger.info(log_message) # Create printout string printout = f""" diff --git a/src/comind/logging_config.py b/src/comind/logging_config.py index 2f4c5f2..e0c9ca9 100644 --- a/src/comind/logging_config.py +++ b/src/comind/logging_config.py @@ -42,9 +42,10 @@ def configure_logger_without_timestamp(logger_name, level=logging.INFO): logger.removeHandler(handler) # Create a new handler - handler = logging.StreamHandler(sys.stdout) + from rich.logging import RichHandler + handler = RichHandler(show_time=False, show_path=False, rich_tracebacks=True, markup=True, enable_link_path=False) - # Create a formatter without timestamps + # Create a formatter without timestamps; RichHandler will use this for prefix and render markup in the message. formatter = logging.Formatter('%(name)s - %(levelname)s - %(message)s') handler.setFormatter(formatter) @@ -54,4 +55,4 @@ def configure_logger_without_timestamp(logger_name, level=logging.INFO): # Prevent propagation to parent loggers (including root) to avoid duplicate logs logger.propagate = False - return logger \ No newline at end of file + return logger -- 2.51.2