Skip to content

Commit 28fa5ff

Browse files
committed
Propagate child loggers to Splunk
This seems not to be happening when handlers are called through the celery apply_async call.
1 parent 3ce7c70 commit 28fa5ff

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

packit_service/worker/tasks.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ def setup_loggers(logger, *args, **kwargs):
120120
logging.getLogger("sandcastle").setLevel(logging.INFO)
121121
# easier debugging
122122
logging.getLogger("packit").setLevel(logging.DEBUG)
123+
logging.getLogger("packit_service").setLevel(logging.DEBUG)
123124

124125
class CustomFormatter(logging.Formatter):
125126
def format(self, record):
@@ -149,6 +150,11 @@ def format(self, record):
149150
project = getenv("PROJECT", "packit")
150151
handler.setFormatter(RFC5424Formatter(msgid=project))
151152
logger.addHandler(handler)
153+
# Also add to root logger to ensure all loggers (including child loggers) inherit it
154+
root_logger = logging.getLogger()
155+
# Check if handler already exists to avoid duplicates
156+
if not any(isinstance(h, logging.handlers.SysLogHandler) for h in root_logger.handlers):
157+
root_logger.addHandler(handler)
152158

153159
package_versions = [
154160
("OGR", ogr_version),

0 commit comments

Comments
 (0)