Stop configuring the root logger on import

logging.basicConfig() at import time in __init__.py silently clobbered the
embedding application's own logging setup. Replace it with a NullHandler so
the library stays silent by default without touching global config.

Also stop MeshCore.__init__ from unconditionally forcing the "meshcore"
logger to INFO when neither debug= nor only_error= is passed - only set a
level when the caller explicitly asks for one, otherwise leave whatever the
app already configured alone.

Document the idiomatic logging setup for consumers in README.md.

Fixes #58
This commit is contained in:
Joey Leake
2026-08-31 13:18:23 -04:00
parent 664ba0c99e
commit 9163efa4f3
3 changed files with 16 additions and 5 deletions
+9
View File
@@ -371,6 +371,15 @@ meshcore = await MeshCore.create_serial("/dev/ttyUSB0", debug=True)
This logs detailed information about commands sent and events received.
meshcore_py does not configure Python's root logger or call `logging.basicConfig()` itself - it only attaches a `NullHandler` so it stays silent by default. To see its logs, configure logging in your own application, e.g.:
```python
import logging
logging.basicConfig(level=logging.INFO)
logging.getLogger("meshcore").setLevel(logging.DEBUG)
```
## Common Examples
### Sending Messages to Contacts