Skip to content
Snippets Groups Projects
Commit ab2b8be2 authored by Jérémy Bobbio (Lunar)'s avatar Jérémy Bobbio (Lunar)
Browse files

Silence “Sentry DSN not provided” warning when attached to a TTY

When running command line tools like `swh alter` or `swh scanner`, there
is rarely a Sentry DSN set. As errors are most often monitored from the
terminal in such configuration, let’s not display a warning that is more
noise than signal.
parent a658a865
No related branches found
No related tags found
1 merge request!386Silence “Sentry DSN not provided” warning when attached to a TTY
Pipeline #10527 passed
......@@ -6,6 +6,7 @@
from importlib.metadata import distribution
import logging
import os
import sys
from typing import Dict, List, Optional
logger = logging.getLogger(__name__)
......@@ -82,7 +83,10 @@ def init_sentry(
)
if sentry_dsn is None and not deferred_init:
logger.warning("Sentry DSN not provided, events will not be sent.")
# Don’t display a warning if there is a controlling terminal
# as errors can be monitored from there.
if not sys.stdout.isatty():
logger.warning("Sentry DSN not provided, events will not be sent.")
import sentry_sdk
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment