Skip to content

Logging setup violates best practices #27

@mdecuir

Description

@mdecuir

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__ .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions