Skip to content

Commit c78fcd4

Browse files
jirhikerclaude
andcommitted
Gate DIE->Dagster log forwarding behind env var (default off)
forward_die_logs is now a no-op unless DIE_FORWARD_LOGS_TO_DAGSTER is truthy. Keeps the Dagster compute log clean by default; enable per deployment when DIE-level logs are needed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 32de27b commit c78fcd4

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

orchestration/logging_bridge.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,19 @@
66
so we never leak handlers across runs.
77
"""
88
import logging
9+
import os
910
from contextlib import contextmanager
1011

1112

13+
def _enabled() -> bool:
14+
return os.environ.get("DIE_FORWARD_LOGS_TO_DAGSTER", "false").strip().lower() in (
15+
"1",
16+
"true",
17+
"yes",
18+
"on",
19+
)
20+
21+
1222
class _DagsterForwardHandler(logging.Handler):
1323
def __init__(self, dagster_logger):
1424
super().__init__()
@@ -24,7 +34,14 @@ def emit(self, record):
2434

2535
@contextmanager
2636
def forward_die_logs(context, level=logging.INFO):
27-
"""Relay root-logger records to `context.log` for the duration of the block."""
37+
"""Relay root-logger records to `context.log` for the duration of the block.
38+
39+
No-op unless the DIE_FORWARD_LOGS_TO_DAGSTER env var is truthy (default off).
40+
"""
41+
if not _enabled():
42+
yield
43+
return
44+
2845
handler = _DagsterForwardHandler(context.log)
2946
handler.setLevel(level)
3047
handler.setFormatter(logging.Formatter("%(name)-30s %(message)s"))

0 commit comments

Comments
 (0)