django-structlog 7.0.0.dev1__tar.gz → 8.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {django-structlog-7.0.0.dev1 → django-structlog-8.0.0}/PKG-INFO +40 -1
- django-structlog-7.0.0.dev1/django_structlog.egg-info/PKG-INFO → django-structlog-8.0.0/README.rst +37 -37
- {django-structlog-7.0.0.dev1 → django-structlog-8.0.0}/django_structlog/__init__.py +1 -2
- {django-structlog-7.0.0.dev1 → django-structlog-8.0.0}/django_structlog/celery/signals.py +1 -1
- {django-structlog-7.0.0.dev1 → django-structlog-8.0.0}/django_structlog/middlewares/request.py +24 -11
- {django-structlog-7.0.0.dev1 → django-structlog-8.0.0}/django_structlog/signals.py +10 -6
- django-structlog-7.0.0.dev1/README.rst → django-structlog-8.0.0/django_structlog.egg-info/PKG-INFO +76 -0
- {django-structlog-7.0.0.dev1 → django-structlog-8.0.0}/pyproject.toml +2 -0
- {django-structlog-7.0.0.dev1 → django-structlog-8.0.0}/LICENSE.rst +0 -0
- {django-structlog-7.0.0.dev1 → django-structlog-8.0.0}/MANIFEST.in +0 -0
- {django-structlog-7.0.0.dev1 → django-structlog-8.0.0}/django_structlog/app_settings.py +0 -0
- {django-structlog-7.0.0.dev1 → django-structlog-8.0.0}/django_structlog/apps.py +0 -0
- {django-structlog-7.0.0.dev1 → django-structlog-8.0.0}/django_structlog/celery/__init__.py +0 -0
- {django-structlog-7.0.0.dev1 → django-structlog-8.0.0}/django_structlog/celery/receivers.py +0 -0
- {django-structlog-7.0.0.dev1 → django-structlog-8.0.0}/django_structlog/celery/steps.py +0 -0
- {django-structlog-7.0.0.dev1 → django-structlog-8.0.0}/django_structlog/commands.py +0 -0
- {django-structlog-7.0.0.dev1 → django-structlog-8.0.0}/django_structlog/middlewares/__init__.py +0 -0
- {django-structlog-7.0.0.dev1 → django-structlog-8.0.0}/django_structlog.egg-info/SOURCES.txt +0 -0
- {django-structlog-7.0.0.dev1 → django-structlog-8.0.0}/django_structlog.egg-info/dependency_links.txt +0 -0
- {django-structlog-7.0.0.dev1 → django-structlog-8.0.0}/django_structlog.egg-info/requires.txt +0 -0
- {django-structlog-7.0.0.dev1 → django-structlog-8.0.0}/django_structlog.egg-info/top_level.txt +0 -0
- {django-structlog-7.0.0.dev1 → django-structlog-8.0.0}/setup.cfg +0 -0
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: django-structlog
|
|
3
|
-
Version:
|
|
3
|
+
Version: 8.0.0
|
|
4
4
|
Summary: Structured Logging for Django
|
|
5
5
|
Author-email: Jules Robichaud-Gagnon <j.robichaudg+pypi@gmail.com>
|
|
6
6
|
License: MIT
|
|
7
7
|
Project-URL: homepage, https://github.com/jrobichaud/django-structlog
|
|
8
8
|
Project-URL: repository, https://github.com/jrobichaud/django-structlog
|
|
9
9
|
Project-URL: documentation, https://django-structlog.readthedocs.io
|
|
10
|
+
Project-URL: tracker, https://github.com/jrobichaud/django-structlog/issues
|
|
11
|
+
Project-URL: changelog, https://django-structlog.readthedocs.io/en/latest/changelog.html
|
|
10
12
|
Classifier: Development Status :: 5 - Production/Stable
|
|
11
13
|
Classifier: Framework :: Django
|
|
12
14
|
Classifier: Framework :: Django :: 3.2
|
|
@@ -399,6 +401,42 @@ Json file (\ ``logs/json.log``\ )
|
|
|
399
401
|
Upgrade Guide
|
|
400
402
|
=============
|
|
401
403
|
|
|
404
|
+
.. _upgrade_8.0:
|
|
405
|
+
|
|
406
|
+
Upgrading to 8.0+
|
|
407
|
+
^^^^^^^^^^^^^^^^^
|
|
408
|
+
|
|
409
|
+
A new keyword argument ``log_kwargs`` was added to the the optional signals:
|
|
410
|
+
- ``django_structlog.signals.bind_extra_request_metadata``;
|
|
411
|
+
- ``django_structlog.signals.bind_extra_request_finished_metadata``;
|
|
412
|
+
- ``django_structlog.signals.bind_extra_request_failed_metadata``.
|
|
413
|
+
|
|
414
|
+
It should not affect you if you have a ``**kwargs`` in the signature of your receivers.
|
|
415
|
+
|
|
416
|
+
``log_kwargs`` is a dictionary containing the log metadata that will be added to their respective logs (``"request_started"``, ``"request_finished"``, ``"request_failed"``).
|
|
417
|
+
|
|
418
|
+
If you use any of these signals, you may need to update your receiver to accept this new argument:
|
|
419
|
+
|
|
420
|
+
.. code-block:: python
|
|
421
|
+
|
|
422
|
+
from django.contrib.sites.shortcuts import get_current_site
|
|
423
|
+
from django.dispatch import receiver
|
|
424
|
+
from django_structlog import signals
|
|
425
|
+
import structlog
|
|
426
|
+
|
|
427
|
+
@receiver(signals.bind_extra_request_metadata)
|
|
428
|
+
def my_receiver(request, logger, log_kwargs, **kwargs): # <- add `log_kwargs` if necessary
|
|
429
|
+
...
|
|
430
|
+
|
|
431
|
+
@receiver(signals.bind_extra_request_finished_metadata)
|
|
432
|
+
def my_receiver_finished(request, logger, response, log_kwargs, **kwargs): # <- add `log_kwargs` if necessary
|
|
433
|
+
...
|
|
434
|
+
|
|
435
|
+
@receiver(signals.bind_extra_request_failed_metadata)
|
|
436
|
+
def my_receiver_failed(request, logger, exception, log_kwargs, **kwargs): # <- add `log_kwargs` if necessary
|
|
437
|
+
...
|
|
438
|
+
|
|
439
|
+
|
|
402
440
|
.. _upgrade_7.0:
|
|
403
441
|
|
|
404
442
|
Upgrading to 7.0+
|
|
@@ -643,6 +681,7 @@ See also the list of `contributors <https://github.com/jrobichaud/django-structl
|
|
|
643
681
|
Acknowledgments
|
|
644
682
|
===============
|
|
645
683
|
|
|
684
|
+
* Very huge thanks to my awesome 🦄 and generous employer `TLM 🩵💜❤️🧡💚🐈⬛ <https://tlmgo.com/en/>`_ for letting me maintain this project on my work hours because it believes in open source.
|
|
646
685
|
* Big thanks to `@ferd <https://github.com/ferd>`_ for his `bad opinions <https://ferd.ca/erlang-otp-21-s-new-logger.html>`_ that inspired the author enough to spend time on this library.
|
|
647
686
|
* `This issue <https://github.com/hynek/structlog/issues/175>`_ helped the author to figure out how to integrate ``structlog`` in Django.
|
|
648
687
|
* `This stack overflow question <https://stackoverflow.com/questions/43855507/configuring-and-using-structlog-with-django>`_ was also helpful.
|
django-structlog-7.0.0.dev1/django_structlog.egg-info/PKG-INFO → django-structlog-8.0.0/README.rst
RENAMED
|
@@ -1,40 +1,3 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: django-structlog
|
|
3
|
-
Version: 7.0.0.dev1
|
|
4
|
-
Summary: Structured Logging for Django
|
|
5
|
-
Author-email: Jules Robichaud-Gagnon <j.robichaudg+pypi@gmail.com>
|
|
6
|
-
License: MIT
|
|
7
|
-
Project-URL: homepage, https://github.com/jrobichaud/django-structlog
|
|
8
|
-
Project-URL: repository, https://github.com/jrobichaud/django-structlog
|
|
9
|
-
Project-URL: documentation, https://django-structlog.readthedocs.io
|
|
10
|
-
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
-
Classifier: Framework :: Django
|
|
12
|
-
Classifier: Framework :: Django :: 3.2
|
|
13
|
-
Classifier: Framework :: Django :: 4.1
|
|
14
|
-
Classifier: Framework :: Django :: 4.2
|
|
15
|
-
Classifier: Framework :: Django :: 5.0
|
|
16
|
-
Classifier: Programming Language :: Python :: 3
|
|
17
|
-
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
-
Classifier: Topic :: System :: Logging
|
|
24
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
25
|
-
Classifier: Operating System :: OS Independent
|
|
26
|
-
Requires-Python: >=3.8
|
|
27
|
-
Description-Content-Type: text/x-rst
|
|
28
|
-
License-File: LICENSE.rst
|
|
29
|
-
Requires-Dist: django>=3.2
|
|
30
|
-
Requires-Dist: structlog>=21.4.0
|
|
31
|
-
Requires-Dist: asgiref>=3.6.0
|
|
32
|
-
Requires-Dist: django-ipware>=6.0.2
|
|
33
|
-
Provides-Extra: celery
|
|
34
|
-
Requires-Dist: celery>=5.1; extra == "celery"
|
|
35
|
-
Provides-Extra: commands
|
|
36
|
-
Requires-Dist: django-extensions>=1.4.9; extra == "commands"
|
|
37
|
-
|
|
38
1
|
.. inclusion-marker-introduction-begin
|
|
39
2
|
|
|
40
3
|
django-structlog
|
|
@@ -399,6 +362,42 @@ Json file (\ ``logs/json.log``\ )
|
|
|
399
362
|
Upgrade Guide
|
|
400
363
|
=============
|
|
401
364
|
|
|
365
|
+
.. _upgrade_8.0:
|
|
366
|
+
|
|
367
|
+
Upgrading to 8.0+
|
|
368
|
+
^^^^^^^^^^^^^^^^^
|
|
369
|
+
|
|
370
|
+
A new keyword argument ``log_kwargs`` was added to the the optional signals:
|
|
371
|
+
- ``django_structlog.signals.bind_extra_request_metadata``;
|
|
372
|
+
- ``django_structlog.signals.bind_extra_request_finished_metadata``;
|
|
373
|
+
- ``django_structlog.signals.bind_extra_request_failed_metadata``.
|
|
374
|
+
|
|
375
|
+
It should not affect you if you have a ``**kwargs`` in the signature of your receivers.
|
|
376
|
+
|
|
377
|
+
``log_kwargs`` is a dictionary containing the log metadata that will be added to their respective logs (``"request_started"``, ``"request_finished"``, ``"request_failed"``).
|
|
378
|
+
|
|
379
|
+
If you use any of these signals, you may need to update your receiver to accept this new argument:
|
|
380
|
+
|
|
381
|
+
.. code-block:: python
|
|
382
|
+
|
|
383
|
+
from django.contrib.sites.shortcuts import get_current_site
|
|
384
|
+
from django.dispatch import receiver
|
|
385
|
+
from django_structlog import signals
|
|
386
|
+
import structlog
|
|
387
|
+
|
|
388
|
+
@receiver(signals.bind_extra_request_metadata)
|
|
389
|
+
def my_receiver(request, logger, log_kwargs, **kwargs): # <- add `log_kwargs` if necessary
|
|
390
|
+
...
|
|
391
|
+
|
|
392
|
+
@receiver(signals.bind_extra_request_finished_metadata)
|
|
393
|
+
def my_receiver_finished(request, logger, response, log_kwargs, **kwargs): # <- add `log_kwargs` if necessary
|
|
394
|
+
...
|
|
395
|
+
|
|
396
|
+
@receiver(signals.bind_extra_request_failed_metadata)
|
|
397
|
+
def my_receiver_failed(request, logger, exception, log_kwargs, **kwargs): # <- add `log_kwargs` if necessary
|
|
398
|
+
...
|
|
399
|
+
|
|
400
|
+
|
|
402
401
|
.. _upgrade_7.0:
|
|
403
402
|
|
|
404
403
|
Upgrading to 7.0+
|
|
@@ -643,6 +642,7 @@ See also the list of `contributors <https://github.com/jrobichaud/django-structl
|
|
|
643
642
|
Acknowledgments
|
|
644
643
|
===============
|
|
645
644
|
|
|
645
|
+
* Very huge thanks to my awesome 🦄 and generous employer `TLM 🩵💜❤️🧡💚🐈⬛ <https://tlmgo.com/en/>`_ for letting me maintain this project on my work hours because it believes in open source.
|
|
646
646
|
* Big thanks to `@ferd <https://github.com/ferd>`_ for his `bad opinions <https://ferd.ca/erlang-otp-21-s-new-logger.html>`_ that inspired the author enough to spend time on this library.
|
|
647
647
|
* `This issue <https://github.com/hynek/structlog/issues/175>`_ helped the author to figure out how to integrate ``structlog`` in Django.
|
|
648
648
|
* `This stack overflow question <https://stackoverflow.com/questions/43855507/configuring-and-using-structlog-with-django>`_ was also helpful.
|
|
@@ -12,7 +12,7 @@ bind_extra_task_metadata = django.dispatch.Signal()
|
|
|
12
12
|
>>> import structlog
|
|
13
13
|
>>>
|
|
14
14
|
>>> @receiver(signals.bind_extra_task_metadata)
|
|
15
|
-
... def
|
|
15
|
+
... def receiver_bind_extra_task_metadata(sender, signal, task=None, logger=None, **kwargs):
|
|
16
16
|
... structlog.contextvars.bind_contextvars(correlation_id=task.request.correlation_id)
|
|
17
17
|
|
|
18
18
|
"""
|
{django-structlog-7.0.0.dev1 → django-structlog-8.0.0}/django_structlog/middlewares/request.py
RENAMED
|
@@ -76,7 +76,11 @@ class RequestMiddleware:
|
|
|
76
76
|
|
|
77
77
|
async def __acall__(self, request):
|
|
78
78
|
await sync.sync_to_async(self.prepare)(request)
|
|
79
|
-
|
|
79
|
+
try:
|
|
80
|
+
response = await self.get_response(request)
|
|
81
|
+
except asyncio.CancelledError:
|
|
82
|
+
logger.warning("request_cancelled")
|
|
83
|
+
raise
|
|
80
84
|
await sync.sync_to_async(self.handle_response)(request, response)
|
|
81
85
|
return response
|
|
82
86
|
|
|
@@ -84,11 +88,17 @@ class RequestMiddleware:
|
|
|
84
88
|
if not hasattr(request, "_raised_exception"):
|
|
85
89
|
self.bind_user_id(request)
|
|
86
90
|
context = structlog.contextvars.get_merged_contextvars(logger)
|
|
91
|
+
|
|
92
|
+
log_kwargs = dict(
|
|
93
|
+
code=response.status_code,
|
|
94
|
+
request=self.format_request(request),
|
|
95
|
+
)
|
|
87
96
|
signals.bind_extra_request_finished_metadata.send(
|
|
88
97
|
sender=self.__class__,
|
|
89
98
|
request=request,
|
|
90
99
|
logger=logger,
|
|
91
100
|
response=response,
|
|
101
|
+
log_kwargs=log_kwargs,
|
|
92
102
|
)
|
|
93
103
|
if response.status_code >= 500:
|
|
94
104
|
level = logging.ERROR
|
|
@@ -99,8 +109,7 @@ class RequestMiddleware:
|
|
|
99
109
|
logger.log(
|
|
100
110
|
level,
|
|
101
111
|
"request_finished",
|
|
102
|
-
|
|
103
|
-
request=self.format_request(request),
|
|
112
|
+
**log_kwargs,
|
|
104
113
|
)
|
|
105
114
|
if isinstance(response, StreamingHttpResponse):
|
|
106
115
|
streaming_content = response.streaming_content
|
|
@@ -142,14 +151,14 @@ class RequestMiddleware:
|
|
|
142
151
|
structlog.contextvars.bind_contextvars(correlation_id=correlation_id)
|
|
143
152
|
ip, _ = get_client_ip(request)
|
|
144
153
|
structlog.contextvars.bind_contextvars(ip=ip)
|
|
154
|
+
log_kwargs = {
|
|
155
|
+
"request": self.format_request(request),
|
|
156
|
+
"user_agent": request.META.get("HTTP_USER_AGENT"),
|
|
157
|
+
}
|
|
145
158
|
signals.bind_extra_request_metadata.send(
|
|
146
|
-
sender=self.__class__, request=request, logger=logger
|
|
147
|
-
)
|
|
148
|
-
logger.info(
|
|
149
|
-
"request_started",
|
|
150
|
-
request=self.format_request(request),
|
|
151
|
-
user_agent=request.META.get("HTTP_USER_AGENT"),
|
|
159
|
+
sender=self.__class__, request=request, logger=logger, log_kwargs=log_kwargs
|
|
152
160
|
)
|
|
161
|
+
logger.info("request_started", **log_kwargs)
|
|
153
162
|
|
|
154
163
|
@staticmethod
|
|
155
164
|
def format_request(request):
|
|
@@ -174,14 +183,18 @@ class RequestMiddleware:
|
|
|
174
183
|
|
|
175
184
|
setattr(request, "_raised_exception", exception)
|
|
176
185
|
self.bind_user_id(request)
|
|
186
|
+
log_kwargs = dict(
|
|
187
|
+
code=500,
|
|
188
|
+
request=self.format_request(request),
|
|
189
|
+
)
|
|
177
190
|
signals.bind_extra_request_failed_metadata.send(
|
|
178
191
|
sender=self.__class__,
|
|
179
192
|
request=request,
|
|
180
193
|
logger=logger,
|
|
181
194
|
exception=exception,
|
|
195
|
+
log_kwargs=log_kwargs,
|
|
182
196
|
)
|
|
183
197
|
logger.exception(
|
|
184
198
|
"request_failed",
|
|
185
|
-
|
|
186
|
-
request=self.format_request(request),
|
|
199
|
+
**log_kwargs,
|
|
187
200
|
)
|
|
@@ -4,7 +4,9 @@ import django.dispatch
|
|
|
4
4
|
bind_extra_request_metadata = django.dispatch.Signal()
|
|
5
5
|
""" Signal to add extra ``structlog`` bindings from ``django``'s request.
|
|
6
6
|
|
|
7
|
-
:param
|
|
7
|
+
:param request: the request returned by the view
|
|
8
|
+
:param logger: the logger
|
|
9
|
+
:param log_kwargs: dictionary of log metadata for the ``request_started`` event. It contains ``request`` and ``user_agent`` keys. You may modify it to add extra information.
|
|
8
10
|
|
|
9
11
|
>>> from django.contrib.sites.shortcuts import get_current_site
|
|
10
12
|
>>> from django.dispatch import receiver
|
|
@@ -12,7 +14,7 @@ bind_extra_request_metadata = django.dispatch.Signal()
|
|
|
12
14
|
>>> import structlog
|
|
13
15
|
>>>
|
|
14
16
|
>>> @receiver(signals.bind_extra_request_metadata)
|
|
15
|
-
... def bind_domain(request, logger, **kwargs):
|
|
17
|
+
... def bind_domain(request, logger, log_kwargs, **kwargs):
|
|
16
18
|
... current_site = get_current_site(request)
|
|
17
19
|
... structlog.contextvars.bind_contextvars(domain=current_site.domain)
|
|
18
20
|
|
|
@@ -21,8 +23,9 @@ bind_extra_request_metadata = django.dispatch.Signal()
|
|
|
21
23
|
bind_extra_request_finished_metadata = django.dispatch.Signal()
|
|
22
24
|
""" Signal to add extra ``structlog`` bindings from ``django``'s finished request and response.
|
|
23
25
|
|
|
24
|
-
:param logger: the logger
|
|
26
|
+
:param logger: the logger
|
|
25
27
|
:param response: the response resulting of the request
|
|
28
|
+
:param log_kwargs: dictionary of log metadata for the ``request_finished`` event. It contains ``request`` and ``code`` keys. You may modify it to add extra information.
|
|
26
29
|
|
|
27
30
|
>>> from django.contrib.sites.shortcuts import get_current_site
|
|
28
31
|
>>> from django.dispatch import receiver
|
|
@@ -30,7 +33,7 @@ bind_extra_request_finished_metadata = django.dispatch.Signal()
|
|
|
30
33
|
>>> import structlog
|
|
31
34
|
>>>
|
|
32
35
|
>>> @receiver(signals.bind_extra_request_finished_metadata)
|
|
33
|
-
... def bind_domain(request, logger, response, **kwargs):
|
|
36
|
+
... def bind_domain(request, logger, response, log_kwargs, **kwargs):
|
|
34
37
|
... current_site = get_current_site(request)
|
|
35
38
|
... structlog.contextvars.bind_contextvars(domain=current_site.domain)
|
|
36
39
|
|
|
@@ -39,8 +42,9 @@ bind_extra_request_finished_metadata = django.dispatch.Signal()
|
|
|
39
42
|
bind_extra_request_failed_metadata = django.dispatch.Signal()
|
|
40
43
|
""" Signal to add extra ``structlog`` bindings from ``django``'s failed request and exception.
|
|
41
44
|
|
|
42
|
-
:param logger: the logger
|
|
45
|
+
:param logger: the logger
|
|
43
46
|
:param exception: the exception resulting of the request
|
|
47
|
+
:param log_kwargs: dictionary of log metadata for the ``request_failed`` event. It contains ``request`` and ``code`` keys. You may modify it to add extra information.
|
|
44
48
|
|
|
45
49
|
>>> from django.contrib.sites.shortcuts import get_current_site
|
|
46
50
|
>>> from django.dispatch import receiver
|
|
@@ -48,7 +52,7 @@ bind_extra_request_failed_metadata = django.dispatch.Signal()
|
|
|
48
52
|
>>> import structlog
|
|
49
53
|
>>>
|
|
50
54
|
>>> @receiver(signals.bind_extra_request_failed_metadata)
|
|
51
|
-
... def bind_domain(request, logger, exception, **kwargs):
|
|
55
|
+
... def bind_domain(request, logger, exception, log_kwargs, **kwargs):
|
|
52
56
|
... current_site = get_current_site(request)
|
|
53
57
|
... structlog.contextvars.bind_contextvars(domain=current_site.domain)
|
|
54
58
|
|
django-structlog-7.0.0.dev1/README.rst → django-structlog-8.0.0/django_structlog.egg-info/PKG-INFO
RENAMED
|
@@ -1,3 +1,42 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: django-structlog
|
|
3
|
+
Version: 8.0.0
|
|
4
|
+
Summary: Structured Logging for Django
|
|
5
|
+
Author-email: Jules Robichaud-Gagnon <j.robichaudg+pypi@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: homepage, https://github.com/jrobichaud/django-structlog
|
|
8
|
+
Project-URL: repository, https://github.com/jrobichaud/django-structlog
|
|
9
|
+
Project-URL: documentation, https://django-structlog.readthedocs.io
|
|
10
|
+
Project-URL: tracker, https://github.com/jrobichaud/django-structlog/issues
|
|
11
|
+
Project-URL: changelog, https://django-structlog.readthedocs.io/en/latest/changelog.html
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Framework :: Django
|
|
14
|
+
Classifier: Framework :: Django :: 3.2
|
|
15
|
+
Classifier: Framework :: Django :: 4.1
|
|
16
|
+
Classifier: Framework :: Django :: 4.2
|
|
17
|
+
Classifier: Framework :: Django :: 5.0
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
25
|
+
Classifier: Topic :: System :: Logging
|
|
26
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
27
|
+
Classifier: Operating System :: OS Independent
|
|
28
|
+
Requires-Python: >=3.8
|
|
29
|
+
Description-Content-Type: text/x-rst
|
|
30
|
+
License-File: LICENSE.rst
|
|
31
|
+
Requires-Dist: django>=3.2
|
|
32
|
+
Requires-Dist: structlog>=21.4.0
|
|
33
|
+
Requires-Dist: asgiref>=3.6.0
|
|
34
|
+
Requires-Dist: django-ipware>=6.0.2
|
|
35
|
+
Provides-Extra: celery
|
|
36
|
+
Requires-Dist: celery>=5.1; extra == "celery"
|
|
37
|
+
Provides-Extra: commands
|
|
38
|
+
Requires-Dist: django-extensions>=1.4.9; extra == "commands"
|
|
39
|
+
|
|
1
40
|
.. inclusion-marker-introduction-begin
|
|
2
41
|
|
|
3
42
|
django-structlog
|
|
@@ -362,6 +401,42 @@ Json file (\ ``logs/json.log``\ )
|
|
|
362
401
|
Upgrade Guide
|
|
363
402
|
=============
|
|
364
403
|
|
|
404
|
+
.. _upgrade_8.0:
|
|
405
|
+
|
|
406
|
+
Upgrading to 8.0+
|
|
407
|
+
^^^^^^^^^^^^^^^^^
|
|
408
|
+
|
|
409
|
+
A new keyword argument ``log_kwargs`` was added to the the optional signals:
|
|
410
|
+
- ``django_structlog.signals.bind_extra_request_metadata``;
|
|
411
|
+
- ``django_structlog.signals.bind_extra_request_finished_metadata``;
|
|
412
|
+
- ``django_structlog.signals.bind_extra_request_failed_metadata``.
|
|
413
|
+
|
|
414
|
+
It should not affect you if you have a ``**kwargs`` in the signature of your receivers.
|
|
415
|
+
|
|
416
|
+
``log_kwargs`` is a dictionary containing the log metadata that will be added to their respective logs (``"request_started"``, ``"request_finished"``, ``"request_failed"``).
|
|
417
|
+
|
|
418
|
+
If you use any of these signals, you may need to update your receiver to accept this new argument:
|
|
419
|
+
|
|
420
|
+
.. code-block:: python
|
|
421
|
+
|
|
422
|
+
from django.contrib.sites.shortcuts import get_current_site
|
|
423
|
+
from django.dispatch import receiver
|
|
424
|
+
from django_structlog import signals
|
|
425
|
+
import structlog
|
|
426
|
+
|
|
427
|
+
@receiver(signals.bind_extra_request_metadata)
|
|
428
|
+
def my_receiver(request, logger, log_kwargs, **kwargs): # <- add `log_kwargs` if necessary
|
|
429
|
+
...
|
|
430
|
+
|
|
431
|
+
@receiver(signals.bind_extra_request_finished_metadata)
|
|
432
|
+
def my_receiver_finished(request, logger, response, log_kwargs, **kwargs): # <- add `log_kwargs` if necessary
|
|
433
|
+
...
|
|
434
|
+
|
|
435
|
+
@receiver(signals.bind_extra_request_failed_metadata)
|
|
436
|
+
def my_receiver_failed(request, logger, exception, log_kwargs, **kwargs): # <- add `log_kwargs` if necessary
|
|
437
|
+
...
|
|
438
|
+
|
|
439
|
+
|
|
365
440
|
.. _upgrade_7.0:
|
|
366
441
|
|
|
367
442
|
Upgrading to 7.0+
|
|
@@ -606,6 +681,7 @@ See also the list of `contributors <https://github.com/jrobichaud/django-structl
|
|
|
606
681
|
Acknowledgments
|
|
607
682
|
===============
|
|
608
683
|
|
|
684
|
+
* Very huge thanks to my awesome 🦄 and generous employer `TLM 🩵💜❤️🧡💚🐈⬛ <https://tlmgo.com/en/>`_ for letting me maintain this project on my work hours because it believes in open source.
|
|
609
685
|
* Big thanks to `@ferd <https://github.com/ferd>`_ for his `bad opinions <https://ferd.ca/erlang-otp-21-s-new-logger.html>`_ that inspired the author enough to spend time on this library.
|
|
610
686
|
* `This issue <https://github.com/hynek/structlog/issues/175>`_ helped the author to figure out how to integrate ``structlog`` in Django.
|
|
611
687
|
* `This stack overflow question <https://stackoverflow.com/questions/43855507/configuring-and-using-structlog-with-django>`_ was also helpful.
|
|
@@ -41,6 +41,8 @@ build-backend = "setuptools.build_meta"
|
|
|
41
41
|
homepage = "https://github.com/jrobichaud/django-structlog"
|
|
42
42
|
repository = "https://github.com/jrobichaud/django-structlog"
|
|
43
43
|
documentation = "https://django-structlog.readthedocs.io"
|
|
44
|
+
tracker = "https://github.com/jrobichaud/django-structlog/issues"
|
|
45
|
+
changelog = "https://django-structlog.readthedocs.io/en/latest/changelog.html"
|
|
44
46
|
|
|
45
47
|
[project.optional-dependencies]
|
|
46
48
|
celery = [
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django-structlog-7.0.0.dev1 → django-structlog-8.0.0}/django_structlog/middlewares/__init__.py
RENAMED
|
File without changes
|
{django-structlog-7.0.0.dev1 → django-structlog-8.0.0}/django_structlog.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{django-structlog-7.0.0.dev1 → django-structlog-8.0.0}/django_structlog.egg-info/requires.txt
RENAMED
|
File without changes
|
{django-structlog-7.0.0.dev1 → django-structlog-8.0.0}/django_structlog.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|