Skip to content

Commit

Permalink
fix(py): Log to stderr not stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
evanpurkhiser committed Oct 18, 2024
1 parent 0ecd4fa commit 0951550
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/sentry/runner/initializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import importlib.metadata
import logging
import os
import sys
from typing import IO, Any

import click
Expand Down Expand Up @@ -259,8 +260,15 @@ def configure_structlog() -> None:

kwargs["processors"].append(JSONRenderer())

is_s4s = os.environ.get("CUSTOMER_ID") == "sentry4sentry"
if is_s4s:
kwargs["logger_factory"] = structlog.PrintLoggerFactory(sys.stderr)

structlog.configure(**kwargs)

if is_s4s:
logging.info("Writing logs to stderr. Expected only in s4s")

lvl = os.environ.get("SENTRY_LOG_LEVEL")

if lvl and lvl not in logging._nameToLevel:
Expand Down

0 comments on commit 0951550

Please sign in to comment.