toggle logging verbosity based on settings.DEBUG

This commit is contained in:
meeb 2023-11-30 18:50:22 +11:00
parent 6c21ff15ab
commit 512b70adad
1 changed files with 6 additions and 2 deletions

View File

@ -1,10 +1,14 @@
import logging
from django.conf import settings
logging_level = logging.DEBUG if settings.DEBUG else logging.INFO
log = logging.getLogger('tubesync')
log.setLevel(logging.DEBUG)
log.setLevel(logging_level)
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
ch.setLevel(logging_level)
formatter = logging.Formatter('%(asctime)s [%(name)s/%(levelname)s] %(message)s')
ch.setFormatter(formatter)
log.addHandler(ch)