avoid double logging of celery
This commit is contained in:
@@ -285,9 +285,16 @@ def setup_celery_logging(**kwargs):
|
||||
"""
|
||||
This handler ensures Celery uses our application logging settings
|
||||
instead of its own. Prevents duplicate log configurations.
|
||||
Also disables console logging if NO_CONSOLE_LOG=1 is set in the environment.
|
||||
"""
|
||||
# Using the root logger's handlers and level preserves our config
|
||||
return logging.getLogger()
|
||||
root_logger = logging.getLogger()
|
||||
import os
|
||||
if os.environ.get("NO_CONSOLE_LOG") == "1":
|
||||
# Remove all StreamHandlers (console handlers) from the root logger
|
||||
handlers_to_remove = [h for h in root_logger.handlers if isinstance(h, logging.StreamHandler)]
|
||||
for h in handlers_to_remove:
|
||||
root_logger.removeHandler(h)
|
||||
return root_logger
|
||||
|
||||
|
||||
# The initialization of a worker will log the worker configuration
|
||||
|
||||
Reference in New Issue
Block a user