Skip to content

Overhaul logger names #3591

@Bibo-Joshi

Description

@Bibo-Joshi

We currently use logging.getLogger(__name__) to get the logger that we use in a module. While this is common practice, this explicitly uses the naming of our files, leading to output like

DEBUG:telegram.ext._updater:Updater started (polling)

This exposes the protected modules that are protected for the reason that users should not use them directly.

I suggest to revisit every call to logging.getLogger in our code base and

  • evaluate whether we need a logger on class-instance, class, or module level
  • evaluate which name that logger should carry. The name should
    • reflect the public API of PTB
    • make it clear to the user which component is doing the logging

If some auxiliary functionality can be used to automate the derivation of the name, this is a welcome addition and can be implemented in a new telegram._utils.logging moduile.

IMO it would be desirable to extend existing logging-related unit tests to check the set name, especially if some automation functionality is used for the name derivation.

Note that so far we have made no promisies about the names of the loggers in the documentation, so that I don't consider this a breaking change. We might want to give a promise in the future.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions