From 4e66b8238dd84a1839e066b0f5658b321717ede5 Mon Sep 17 00:00:00 2001 From: Michael Meier Date: Sun, 15 May 2022 22:14:47 +0200 Subject: [PATCH] chore(backend): do not override log formating on startup enable color config in logconfig file, if neccesary --- upnpavcontrol/web/application.py | 3 --- uvicorn-log-config.yml | 13 ++++++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/upnpavcontrol/web/application.py b/upnpavcontrol/web/application.py index 09996df6..bcf00f17 100644 --- a/upnpavcontrol/web/application.py +++ b/upnpavcontrol/web/application.py @@ -71,12 +71,9 @@ def create_control_point_from_settings(): @app.on_event("startup") def setup_logging(): - import colorlog import logging level = logging.WARNING if settings.QUIET else logging.INFO level = logging.DEBUG if settings.DEBUG else level - colorlog.basicConfig(level=level, - format='%(log_color)s%(levelname)s%(reset)s:%(yellow)s%(name)s%(reset)s: %(message)s') logging.getLogger('async_upnp_client').setLevel(logging.INFO) diff --git a/uvicorn-log-config.yml b/uvicorn-log-config.yml index 7789acbe..58f1154f 100644 --- a/uvicorn-log-config.yml +++ b/uvicorn-log-config.yml @@ -1,16 +1,23 @@ version: 1 formatters: - simple: - format: '%(asctime)s - %(name)s - %(levelname)s - %(message)s' + color: + "()": "colorlog.ColoredFormatter" + format: '%(asctime)s %(log_color)s%(levelname)s%(reset)s %(yellow)s%(name)-15s%(reset)s %(blue)s%(message)s%(reset)s' + datefmt: '%Y-%m-%d %H:%M:%S' + default: + format: '%(asctime)s %(levelname)-8s %(name)-15s %(message)s' + datefmt: '%Y-%m-%d %H:%M:%S' handlers: console: class: logging.StreamHandler level: DEBUG - formatter: simple + formatter: color stream: ext://sys.stdout loggers: upnpavcontrol: level: DEBUG + upnpavcontrol.core.discovery: + level: WARNING root: level: INFO handlers: [console] \ No newline at end of file