From 00fe611b86d23523710da2eecd1470861968b224 Mon Sep 17 00:00:00 2001 From: Stan Triepels <1939656+GDay@users.noreply.github.com> Date: Sat, 15 Oct 2022 17:39:51 +0200 Subject: [PATCH] Use logger.hasHandlers() to setup fallback logging (#13) Instead of checking if the django-q logger has any handlers directly, use the hasHandlers [1] method, which will check if any parent loggers have handlers as well. This fixes a bug where django-q configures it's own logging even though the root logger has a handler set 1. https://docs.python.org/3/library/logging.html#logging.Logger.hasHandlers Co-authored-by: Wesley Ellis --- django_q/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django_q/conf.py b/django_q/conf.py index f9ecd23..82f6b87 100644 --- a/django_q/conf.py +++ b/django_q/conf.py @@ -214,7 +214,7 @@ class Conf: logger = logging.getLogger("django-q") # Set up standard logging handler in case there is none -if not logger.handlers: +if not logger.hasHandlers(): logger.setLevel(level=getattr(logging, Conf.LOG_LEVEL)) logger.propagate = False formatter = logging.Formatter(