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

Logging setup violates best practices #27

Open
mdecuir opened this issue Nov 7, 2023 · 0 comments
Open

Logging setup violates best practices #27

mdecuir opened this issue Nov 7, 2023 · 0 comments

Comments

@mdecuir
Copy link

mdecuir commented Nov 7, 2023

I just ran into an issue when adding ipdata as a library used by my project that the log outputs I received suddenly changed formatting. Upon digging into the issue, I found that the ipdata library calls logging.basicConfig to set a RichHandler instance for the root logger if one is not otherwise defined. It then writes its logs to a logger named "rich".

This violates several of python's best practices regarding configuring logging within a library: https://docs.python.org/3/howto/logging.html#configuring-logging-for-a-library

In particular, the issue that is causing problems for my application is that the app does not define any handlers on the root logger, but when we started using ipdata, all of a sudden logs from all of our 3rd party libraries were showing up in our log and in strange formats, resulting in further downstream frustrations.

To be compliant with python best practices, I believe that the logging.basicConfig call should be removed from the ipdata library and the logger name used by the library should be updated to __name__ .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant