Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make logging level of the django app configurable #2078

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
2 changes: 2 additions & 0 deletions dandiapi/api/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def ready(self):
import dandiapi.api.checks # noqa: F401, RUF100
import dandiapi.api.signals # noqa: F401

logging.getLogger().setLevel(settings.DANDI_LOG_LEVEL)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @waxlamp for catching the initial limitation! but I do not think we should go this wild, what about affecting only dandi ? i.e. smth like

Suggested change
logging.getLogger().setLevel(settings.DANDI_LOG_LEVEL)
logging.getLogger(__name__.split('.', 1)[0]).setLevel(settings.DANDI_LOG_LEVEL)

? otherwise, if to debug our code we turn to DEBUG level globally -- could lead to excessive amount of noise from all kinds of libraries we use. WDYT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see what you were going for now. I've added this back (along with explanatory comment) in dc3549d.


if hasattr(settings, 'SENTRY_DSN'):
sentry_sdk.init(
dsn=settings.SENTRY_DSN,
Expand Down
1 change: 1 addition & 0 deletions dandiapi/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def mutate_configuration(configuration: type[ComposedConfiguration]):
DANDI_DANDISETS_BUCKET_PREFIX = values.Value(default='', environ=True)
DANDI_DANDISETS_LOG_BUCKET_NAME = values.Value(environ_required=True)
DANDI_DANDISETS_EMBARGO_LOG_BUCKET_NAME = values.Value(environ_required=True)
DANDI_LOG_LEVEL = values.Value(default='INFO', environ=True)
DANDI_ZARR_PREFIX_NAME = values.Value(default='zarr', environ=True)

# Mainly applies to unembargo
Expand Down
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ passenv =
DJANGO_DANDI_API_URL
DJANGO_DANDI_JUPYTERHUB_URL
DJANGO_DANDI_DEV_EMAIL
DJANGO_DANDI_LOG_LEVEL
DANDI_ALLOW_LOCALHOST_URLS
extras =
dev
Expand All @@ -69,6 +70,7 @@ passenv =
DJANGO_DANDI_API_URL
DJANGO_DANDI_JUPYTERHUB_URL
DJANGO_DANDI_DEV_EMAIL
DJANGO_DANDI_LOG_LEVEL
extras =
dev
commands =
Expand Down