Skip to content

logging.Formatter and logging.Filter are missing __repr__ #145650

@JackDanger

Description

@JackDanger

logging.Handler and logging.StreamHandler both have useful repr implementations:

>>> import logging
>>> logging.StreamHandler()
<StreamHandler <stderr> (NOTSET)>

But Formatter and Filter don't, so you just get the default unhelpful object repr:

>>> logging.Formatter('%(message)s')
<logging.Formatter object at 0x...>
>>> logging.Filter('myapp')
<logging.Filter object at 0x...>

These should have repr consistent with the existing style, e.g.:

>>> logging.Formatter('%(message)s')
<Formatter (%(message)s)>
>>> logging.Filter('myapp')
<Filter (myapp)>

This would help when inspecting logging configurations in the REPL or debugger.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions