Jules Robichaud-Gagnon
Jules Robichaud-Gagnon
Please let me know how it went.
Have you considered using the signal [`bind_extra_request_metadata`](https://django-structlog.readthedocs.io/en/latest/api_documentation.html#django_structlog.signals.bind_extra_request_metadata) to do what you need to do? ```python from django.dispatch import receiver from django_structlog import signals import structlog @receiver(signals.bind_extra_request_metadata) def bind_correlation_id(request, logger, log_kwargs,...
To retrieve the values you can do it this way: ```python import structlog import logging logger = logging.getLogger(__name__) ... context = structlog.contextvars.get_merged_contextvars(logger) if "correlation_id" in context: ... # do something...
@konchristopoulos did that solve your issue?
maybe you need to add `"propagate": False` See: this issue: https://github.com/jrobichaud/django-structlog/issues/483#issuecomment-1991649842
in your code (or any of your library) do you do: ```python import logging logging.info("something") ``` As noted in this issue, the root logger breaks logging in some situations: https://github.com/jrobichaud/django-structlog/issues/274
try to isolate the problem by methodically: 1: remove apps from installed apps and commenting code using third party library. 2: check if the problem still occur 3: repeat In...
To debug I would put a breakpoint exactly at these lines: https://github.com/python/cpython/blob/8d61a71f9c81619e34d4a30b625922ebc83c561b/Lib/logging/__init__.py#L2167 https://github.com/python/cpython/blob/8d61a71f9c81619e34d4a30b625922ebc83c561b/Lib/logging/__init__.py#L2183 https://github.com/python/cpython/blob/8d61a71f9c81619e34d4a30b625922ebc83c561b/Lib/logging/__init__.py#L2201 https://github.com/python/cpython/blob/8d61a71f9c81619e34d4a30b625922ebc83c561b/Lib/logging/__init__.py#L2211 https://github.com/python/cpython/blob/8d61a71f9c81619e34d4a30b625922ebc83c561b/Lib/logging/__init__.py#L2221 https://github.com/python/cpython/blob/8d61a71f9c81619e34d4a30b625922ebc83c561b/Lib/logging/__init__.py#L2231
The workaround for the moment is to create a custom `MigratorTestCase`. ```python from django_test_migrations.contrib.unittest_case import MigratorTestCase from django_test_migrations.migrator import Migrator class ManualMigratorTestCase(MigratorTestCase): def setUp(self) -> None: self._migrator = Migrator(self.database_name) self.old_state...
Before using `django-test-migrations`, I was using [django_migration_testcase](https://github.com/plumdog/django_migration_testcase?tab=readme-ov-file#quickstart) and it is how it was working. `django-test-migrations` is much more robust in my opinion but I still miss this behaviour of that...