mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-09-29 12:30:45 +03:00
pySim.log: apply cmd2 colors through _style()
The color scheme takes either - a raw escape sequence like "\033[33m" (pySim-read, pySim-prog, contrib/csv-to-pgsql.py) - a cmd2 color object (pySim-shell) Color of cmd2 >= 3.0.0 is a StrEnum, which led to pySim-shell warnings like yellowWARNING: EF.DIR seems to be empty! with a stray reset at the end. Fixed by exclusing Enum from the raw sequence branch. Change-Id: I8bae9fc3c54f1dab481d743d3b68e32e9d09267a
This commit is contained in:
+2
-1
@@ -24,6 +24,7 @@
|
||||
#
|
||||
|
||||
import logging
|
||||
import enum
|
||||
import cmd2
|
||||
from packaging import version
|
||||
|
||||
@@ -126,7 +127,7 @@ class PySimLogger:
|
||||
formatted_message = logging.Formatter.format(PySimLogger.__formatter, record)
|
||||
color = PySimLogger.colors.get(record.levelno)
|
||||
if color:
|
||||
if isinstance(color, str):
|
||||
if isinstance(color, str) and not isinstance(color, enum.Enum):
|
||||
PySimLogger.print_callback(color + formatted_message + "\033[0m")
|
||||
else:
|
||||
PySimLogger.print_callback(_style(formatted_message, fg = color))
|
||||
|
||||
Reference in New Issue
Block a user