From ba3da6d92f4817cace42cbe5d4bb4699e4077388 Mon Sep 17 00:00:00 2001 From: kingbri Date: Mon, 11 Mar 2024 00:28:48 -0400 Subject: [PATCH] Logging: Escape rich markup sequences Rich markup sequences inside the log string were causing issues with printing. Fix this by using their escape function. Signed-off-by: kingbri --- common/logger.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/logger.py b/common/logger.py index f65e418..3498b62 100644 --- a/common/logger.py +++ b/common/logger.py @@ -5,6 +5,7 @@ Internal logging utility. import logging from loguru import logger from rich.console import Console +from rich.markup import escape from rich.progress import ( Progress, TextColumn, @@ -32,7 +33,7 @@ def get_loading_progress_bar(): ) -def _log_formatter(record: dict) -> str: +def _log_formatter(record: dict): """Log message formatter.""" color_map = { @@ -54,6 +55,9 @@ def _log_formatter(record: dict) -> str: # Replace once loguru allows for turning off str.format message = message.replace("{", "{{").replace("}", "}}").replace("<", "\<") + + # Escape markup tags from Rich + message = escape(message) lines = message.splitlines() fmt = ""