Skip to content

[FEATURE] Change behavior of logging in external packages #3743

@lemontree210

Description

@lemontree210

What kind of feature are you missing? Where do you notice a shortcoming of PTB?

One particular problem that we encountered is that, starting with v.0.24.1, httpx logs all ordinary requests at INFO level, which litters the log of a PTB user. It is understandable that for httpx it is a "high-level" enough event for it to be logged at INFO level, but it is not necessary for our users.

We can solve it as one particular problem (as @Poolitzer rightly points out, httpx is PTB's default backend, and this fact makes a difference: logging small operations of a non-default library would possibly make more sense) or as a general problem of allowing the user to set logging levels of external libraries.

Describe the solution you'd like

I'm not sure what an ideal solution would look like. One solution would be setting logging level for httpx's logger to WARNING in the main script. We could simply notify users of this solution in the examples and FAQ in our Wiki.

# PTB's logger still has level INFO: we set a different logging level for httpx only
logging.getLogger("httpx").setLevel(logging.WARNING)

However, as @Bibo-Joshi points out, it's not very desirable to make settings for dependencies. This can be somewhat compensated by highlighting the solution in the examples.

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    ⚙️ examplesaffected functionality: examples

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions