Make logs prettier

This commit is contained in:
kramo
2023-06-29 15:39:29 +02:00
parent f5b527cc51
commit 455c6891d8

View File

@@ -20,6 +20,7 @@
import logging import logging
import logging.config as logging_dot_config import logging.config as logging_dot_config
import os import os
import platform
import subprocess import subprocess
import sys import sys
@@ -41,7 +42,7 @@ def setup_logging():
"version": 1, "version": 1,
"formatters": { "formatters": {
"file_formatter": { "file_formatter": {
"format": "%(asctime)s: %(levelname)s: %(message)s", "format": "%(asctime)s - %(levelname)s: %(message)s",
"datefmt": "%M:%S", "datefmt": "%M:%S",
}, },
"console_formatter": { "console_formatter": {
@@ -92,9 +93,8 @@ def log_system_info():
"""Log system debug information""" """Log system debug information"""
logging.debug("Starting %s v%s (%s)", shared.APP_ID, shared.VERSION, shared.PROFILE) logging.debug("Starting %s v%s (%s)", shared.APP_ID, shared.VERSION, shared.PROFILE)
logging.debug("System: %s", sys.platform)
logging.debug("Python version: %s", sys.version) logging.debug("Python version: %s", sys.version)
if os.getenv("FLATPAK_ID"): if os.getenv("FLATPAK_ID") == shared.APP_ID:
process = subprocess.run( process = subprocess.run(
("flatpak-spawn", "--host", "flatpak", "--version"), ("flatpak-spawn", "--host", "flatpak", "--version"),
capture_output=True, capture_output=True,
@@ -102,11 +102,8 @@ def log_system_info():
check=False, check=False,
) )
logging.debug("Flatpak version: %s", process.stdout.rstrip()) logging.debug("Flatpak version: %s", process.stdout.rstrip())
logging.debug("Platform: %s", platform.platform())
if os.name == "posix": if os.name == "posix":
uname = os.uname() for key, value in platform.uname()._asdict().items():
logging.debug("Uname info:") logging.debug("\t%s: %s", key.title(), value)
logging.debug("\tsysname: %s", uname.sysname)
logging.debug("\trelease: %s", uname.release)
logging.debug("\tversion: %s", uname.version)
logging.debug("\tmachine: %s", uname.machine)
logging.debug("" * 37) logging.debug("" * 37)