Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
lemontree210 opened this issue Jun 4, 2023 · 5 comments · Fixed by #3746
Closed

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

lemontree210 opened this issue Jun 4, 2023 · 5 comments · Fixed by #3746
Labels

Comments

@lemontree210
Copy link
Member

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

@Bibo-Joshi
Copy link
Member

Yes, I'd argue that ading the snippet the examples should suffice. My reasoning: Those, who know how the logging module works, know how to silence httpx. Those, who do not, are unlikely to configure logging on their own in the first place, so the logging.basicConfig(…) in our examples is likely the reason why they see the httpx logs in the first place.

@lemontree210
Copy link
Member Author

lemontree210 commented Jun 5, 2023

I agree. If there are no objections from @Poolitzer , @harshil21 or @clot27 , I can add these lines with a comment to all examples.

@harshil21
Copy link
Member

@lemontree210 I'm okay with that solution, I just hope the users don't get annoyed too much if they miss that line.

@clot27
Copy link
Member

clot27 commented Jun 5, 2023

@lemontree210 Fine by me

@Poolitzer
Copy link
Member

Yep, I think that is the best solution

@github-actions github-actions bot locked and limited conversation to collaborators Jun 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants