Have test client reload logging when logging setting changed
When changing the LOGGING setting (eg in tests), logging config isn't reconfigured to match.
This can be fairly easily added in a project:
@receiver(setting_changed)
def reload_logging_config(*, setting: str, **kwargs: Any) -> None:
if setting in {"LOGGING", "LOGGING_CONFIG"}:
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
But it would be nice if this was handled by default. This snippet appears to do what I need, but there might be edge cases I've not considered.
Change History
(8)
| Component: |
Core (Other) → Testing framework
|
| Summary: |
Reload logging when logging setting changed → Have test client reload logging when logging setting changed
|
| Triage Stage: |
Unreviewed → Accepted
|
| Type: |
Uncategorized → Cleanup/optimization
|
| Has patch: |
set
|
| Owner: |
set to SnippyCodes
|
| Status: |
new → assigned
|
| Patch needs improvement: |
set
|
| Patch needs improvement: |
unset
|
| Patch needs improvement: |
set
|
| Patch needs improvement: |
unset
|
| Triage Stage: |
Accepted → Ready for checkin
|
| Resolution: |
→ fixed
|
| Status: |
assigned → closed
|
Assuming we're to add this in django/test/signals.py, that makes good sense to me and fits right in with the other receivers there.