38 lines
1.0 KiB
Python
38 lines
1.0 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
# Copyright (c) 2025-2026 Renato Xavier da Silveira Rosa
|
|
# See [LICENSE](./LICENSE) or [BSD-3-Clause-Clear](https://spdx.org/licenses/BSD-3-Clause-Clear.html)
|
|
# ============================================================
|
|
# Logging
|
|
# ============================================================
|
|
|
|
import logging
|
|
import os
|
|
import re
|
|
import sys
|
|
import pprint
|
|
|
|
# Globals
|
|
logging.basicConfig(
|
|
# 50=CRITICAL/FATAL, 40=ERROR, 30=WARN/WARNING, 20=INFO, 10=DEBUG, 0=NOTSET
|
|
# loglevel_map = logging.getLevelNamesMapping()
|
|
level=logging.INFO,
|
|
format="%(asctime)s %(levelname)s %(message)s",
|
|
)
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
# Logging utils
|
|
def print(message):
|
|
pp = pprint.PrettyPrinter(
|
|
indent=4,
|
|
width=os.get_terminal_size().columns,
|
|
compact=False,
|
|
depth=None
|
|
)
|
|
if isinstance(message, (dict, list, tuple, set)):
|
|
formatted = pp.pformat(message)
|
|
print(formatted.replace("', '", "',\n'"))
|
|
else:
|
|
pp.pprint(message) |