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 <bdashore3@proton.me>
This commit is contained in:
kingbri 2024-03-11 00:28:48 -04:00
parent 4cc0b59bdc
commit ba3da6d92f

View file

@ -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 = ""