Opened 3 weeks ago

Closed 4 hours ago

#36958 closed Cleanup/optimization (fixed)

Have test client reload logging when logging setting changed

Reported by: Jake Howard Owned by: SnippyCodes
Component: Testing framework Version: 6.0
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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)

comment:1 by Jacob Walls, 3 weeks ago

Component: Core (Other)Testing framework
Summary: Reload logging when logging setting changedHave test client reload logging when logging setting changed
Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/optimization

(eg in tests)

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.

comment:2 by SnippyCodes, 3 weeks ago

Has patch: set
Owner: set to SnippyCodes
Status: newassigned

comment:3 by JaeHyuckSa, 3 weeks ago

Patch needs improvement: set

comment:4 by JaeHyuckSa, 3 weeks ago

Patch needs improvement: unset

comment:5 by JaeHyuckSa, 2 weeks ago

Patch needs improvement: set

comment:6 by SnippyCodes, 10 days ago

Patch needs improvement: unset

comment:7 by Jacob Walls, 4 hours ago

Triage Stage: AcceptedReady for checkin

comment:8 by Jacob Walls <jacobtylerwalls@…>, 4 hours ago

Resolution: fixed
Status: assignedclosed

In 2d7f899d:

Fixed #36958 -- Reloaded logging config when logging settings are changed in tests.

Thanks JaeHyuck Sa and Jake Howard for the reviews.

Note: See TracTickets for help on using tickets.
Back to Top