mirror of
https://github.com/django-q2/django-q2.git
synced 2026-09-15 13:37:56 +08:00
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 <wellis@benchsci.com>
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user