google / mobly

E2E test framework for tests with complex environment requirements.
https://github.com/google/mobly
Apache License 2.0
628 stars 175 forks source link

Why does mobly use the root logger? #757

Closed cpagravel closed 3 years ago

cpagravel commented 3 years ago

Isn't use of the root logger bad practice? I'll quote the Python documentation for libraries (https://docs.python.org/3/howto/logging.html#configuring-logging-for-a-library)

Note It is strongly advised that you do not add any handlers other than NullHandler to your library’s loggers. This is because the configuration of handlers is the prerogative of the application developer who uses your library. The application developer knows their target audience and what handlers are most appropriate for their application: if you add handlers ‘under the hood’, you might well interfere with their ability to carry out unit tests and deliver logs which suit their requirements.

Using the root logger will call basicConfig and subsequently add handlers to the root logger which is undesirable for an application developer who wants to control the logging for their requirements.

xpconanfan commented 3 years ago

We do use the default logger. We attach some extra configs to it.

xpconanfan commented 3 years ago

Discussed offline