equinor / fmu-sumo

Interaction with Sumo in the FMU context
https://fmu-sumo.readthedocs.io/en/latest/
Apache License 2.0
0 stars 6 forks source link

Remove `logging.NullHandler` #183

Closed anders-kiaer closed 1 year ago

anders-kiaer commented 1 year ago

Closes #181.

Below snippet is copied from https://docs.python.org/3/howto/logging.html. Based on that I would argue it is better in this case to use default Python behavior in this case (i.e. not impose a NullHandler).

If for some reason you don’t want these messages printed in the absence of any logging configuration, you can attach a do-nothing handler to the top-level logger for your library. This avoids the message being printed, since a handler will always be found for the library’s events: it just doesn’t produce any output. If the library user configures logging for application use, presumably that configuration will add some handlers, and if levels are suitably configured then logging calls made in library code will send output to those handlers, as normal.

A do-nothing handler is included in the logging package: NullHandler (since Python 3.1). An instance of this handler could be added to the top-level logger of the logging namespace used by the library (if you want to prevent your library’s logged events being output to sys.stderr in the absence of logging configuration).

daniel-sol commented 1 year ago

Agree.