Skip to content
Snippets Groups Projects
Commit fa85d662 authored by David Trattnig's avatar David Trattnig
Browse files

feat(SU): add JSON debug log method

parent 018ba26b
No related branches found
No related tags found
1 merge request!35ORM-less scheduling
......@@ -22,8 +22,10 @@ A collection of all kinds of simplifications.
"""
import datetime
import json
import time
from enum import Enum
from logging import Logger
class SimpleUtil:
......@@ -175,6 +177,18 @@ class SimpleUtil:
"""
return TerminalColors.CYAN.value + text + TerminalColors.ENDC.value
@staticmethod
def log_json(logger: Logger, json_data: dict):
"""
Write formatted JSON to the debug logger.
Args:
logger (Logger): The logger.
json_data (dict): The json object.
"""
json_str = json.dumps(json_data, sort_keys=True, indent=2, separators=(",", ": "))
logger.debug(SimpleUtil.cyan(json_str))
class TerminalColors(Enum):
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment