Skip to content

Commit

Permalink
Merge pull request #1491 from GSA/notify-api-1488
Browse files Browse the repository at this point in the history
stop workers from propagating logs
  • Loading branch information
ccostino authored Dec 19, 2024
2 parents 5a6980f + a45e411 commit 7c7f96d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging as real_logging
import os
import secrets
import string
Expand Down Expand Up @@ -36,6 +37,9 @@ def init_app(self, app):

# Configure Celery app with options from the main app config.
self.config_from_object(app.config["CELERY"])
self.conf.worker_hijack_root_logger = False
logger = real_logging.getLogger("celery")
logger.propagate = False

def send_task(self, name, args=None, kwargs=None, **other_kwargs):
other_kwargs["headers"] = other_kwargs.get("headers") or {}
Expand Down
2 changes: 2 additions & 0 deletions notifications_utils/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ def init_app(app):
for logger_instance, handler in product(loggers, handlers):
logger_instance.addHandler(handler)
logger_instance.setLevel(loglevel)
logger_instance.propagate = False
warning_loggers = [logging.getLogger("boto3"), logging.getLogger("s3transfer")]
for logger_instance, handler in product(warning_loggers, handlers):
logger_instance.addHandler(handler)
logger_instance.setLevel(logging.WARNING)
logger_instance.propagate = False

# Suppress specific loggers to prevent leaking sensitive info
logging.getLogger("boto3").setLevel(logging.ERROR)
Expand Down

0 comments on commit 7c7f96d

Please sign in to comment.