Skip to content

Commit

Permalink
chore(backend): do not override log formating on startup
Browse files Browse the repository at this point in the history
                enable color config in logconfig file, if neccesary
  • Loading branch information
mikedevnull committed May 15, 2022
1 parent f675253 commit 4e66b82
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
3 changes: 0 additions & 3 deletions upnpavcontrol/web/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
13 changes: 10 additions & 3 deletions uvicorn-log-config.yml
Original file line number Diff line number Diff line change
@@ -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]

0 comments on commit 4e66b82

Please sign in to comment.