Skip to content

Commit 49700d2

Browse files
committed
fix: consolidate global exception logging
1 parent daa97c9 commit 49700d2

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/codegen/shared/logging/get_logger.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,16 @@ def _get_telemetry_config():
6262
_telemetry_config_checked = True
6363

6464
try:
65-
from codegen.cli.telemetry.consent import ensure_telemetry_consent
65+
# Use non-prompting config loader to avoid consent prompts during logging setup
66+
from codegen.configs.models.telemetry import TelemetryConfig
67+
from codegen.configs.constants import GLOBAL_ENV_FILE
6668

67-
_telemetry_config = ensure_telemetry_consent()
69+
_telemetry_config = TelemetryConfig(env_filepath=GLOBAL_ENV_FILE)
6870
except ImportError:
6971
# Telemetry dependencies not available
7072
_telemetry_config = None
7173
except Exception:
72-
# Other setup errors
74+
# Other setup errors - fallback to console logging
7375
_telemetry_config = None
7476

7577
return _telemetry_config
@@ -100,7 +102,7 @@ def _get_otel_handler():
100102

101103
def get_logger(name: str, level: int = logging.INFO) -> logging.Logger:
102104
logger = _setup_logger(name, level)
103-
_setup_exception_logging(logger)
105+
# Note: Global exception handling is managed by cli/telemetry/exception_logger.py
104106
return logger
105107

106108

@@ -152,9 +154,4 @@ def _setup_logger(name: str, level: int = logging.INFO) -> logging.Logger:
152154
return logger
153155

154156

155-
def _setup_exception_logging(logger: logging.Logger) -> None:
156-
def log_exception(exc_type, exc_value, exc_traceback):
157-
logger.exception("Uncaught exception", exc_info=(exc_type, exc_value, exc_traceback))
158-
159-
# Set the log_exception function as the exception hook
160-
sys.excepthook = log_exception
157+
# Note: Exception logging is handled by cli/telemetry/exception_logger.py

0 commit comments

Comments
 (0)