[ENHANCEMENT] Remove logger-initialization from Pastas #733
Labels
enhancement
Indicates improvement of existing features
priority 1
normal, deal with in the foreseeable future
Describe the proposed enhancement
Right now when importing pastas a specific logger for Pastas is initialized, by the following two lines in
__init__.py
:This adds a logger with a default level of "INFO". This is useful, as the user then sees all messages in his console. For example, when running example.py (with PR 678), you see:
If the user wants to change the log-level to WARNING, he can use the code
ps.set_log_level("WARNING")
, and you can remove the logger with the lineps.utils.remove_console_handler()
. This works, but is made up by us (me), and I think is not the general way to do it Python. Integrating Pastas in other packages is therefore not so straightforward, and may result in double log-messages: one of the pastas-logger, and one of the logger initiated by the user.Therefore, it might be better to not initialize a logger in
__init__.py
anymore, by removing the two lines at the top of this message. Then, by default of the logging-package, only warnings will be displayed. When running example.py (with PR 678) you then see:If as user wants to see log-messages of other log-levels, he can set this up with the logging-package (https://docs.python.org/3/library/logging.html):
When running example.py (with PR 678) you then see:
Removing the logger-initialization from the import of Pastas will improve integration in people's scripts. However, it may result in people missing info-messages, as is shown above. This may be a good change for Pastas 2.0.
The text was updated successfully, but these errors were encountered: