Logging setup
heilerich opened this issue · 2 comments
Hi there,
thank you for your awesome work here! I just have one tiny problem with your module:
Importing your module breaks the logging setup of the importing module because you're calling basicConfig (which cannot be used twice) on import here
python-fhem/fhem/fhem/__init__.py
Line 36 in f466959
I think it would be good practice to remove that call entirely so that the user of the module can decide how he want's to setup his logger. If you insist on setting the logLevel I would suggest using logger.setLevel
which only modifies your own logger.
An alternative would be calling basicConfig in your class initialization, in case the user hasn't done it so far. This ensures that a logger is properly setup but doesn't overwrite anything if the user has already done his own logging setup (which usually happens after importing modules but before initializing any classes).
But as I said, I would leave the choices of logging setup to the user. Everyone has different loggging needs ;)
Thanks a lot!
You are right. I removed the call to basicConfig(), since loglevel is anyway setup during the creation of the objects.
A new version 0.5.1 is on pypi.
Thanks for the quick fix 👍