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:
parent
4cc0b59bdc
commit
ba3da6d92f
1 changed files with 5 additions and 1 deletions
|
|
@ -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 = ""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue