Skip to content

Commit e36faa8

Browse files
committed
Use structlog in debug toolbar setup
1 parent ad4e687 commit e36faa8

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

config/settings/debug_toolbar/setup.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import logging
2-
1+
import structlog
32
from django.urls import include, path
43

5-
logger = logging.getLogger("configuration")
4+
logger = structlog.getLogger("styleguide_example.configuration")
65

76

87
def show_toolbar(*args, **kwargs) -> bool:
8+
log = logger.bind()
9+
910
"""
1011
The general idea is the following:
1112
@@ -30,7 +31,7 @@ def show_toolbar(*args, **kwargs) -> bool:
3031
try:
3132
import debug_toolbar # noqa
3233
except ImportError:
33-
logger.info("No installation found for: django_debug_toolbar")
34+
log.info("django_debug_toolbar.setup", message="No installation found for: django_debug_toolbar")
3435
return False
3536

3637
return True
@@ -43,8 +44,10 @@ class DebugToolbarSetup:
4344

4445
@staticmethod
4546
def do_settings(INSTALLED_APPS, MIDDLEWARE, middleware_position=None):
47+
log = logger.bind()
48+
4649
_show_toolbar: bool = show_toolbar()
47-
logger.info(f"Django Debug Toolbar in use: {_show_toolbar}")
50+
log.info("django_debuhg_toolbar.setup", message=f"Django Debug Toolbar in use: {_show_toolbar}")
4851

4952
if not _show_toolbar:
5053
return INSTALLED_APPS, MIDDLEWARE

0 commit comments

Comments
 (0)