Skip to content

Commit

Permalink
bleak: include %(threadName)s in BLEAK_LOGGING (#1144)
Browse files Browse the repository at this point in the history
This adds `%(threadName)s` to `FORMAT` passed to `logging.basicConfig()`
when `BLEAK_LOGGING` is used. This can be useful to debug OS callbacks
on background threads.
  • Loading branch information
dlech authored Nov 23, 2022
1 parent 5e7d191 commit b39beec
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Changed
* ``BLEDevice`` now uses ``__slots__`` to reduce memory usage.
* ``BaseBleakClient.services`` is now ``None`` instead of empty service collection
until services are discovered.
* Include thread name in ``BLEAK_LOGGING`` output. Merged #1144.

Fixed
-----
Expand Down
2 changes: 1 addition & 1 deletion bleak/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
_logger = logging.getLogger(__name__)
_logger.addHandler(logging.NullHandler())
if bool(os.environ.get("BLEAK_LOGGING", False)):
FORMAT = "%(asctime)-15s %(name)-8s %(levelname)s: %(message)s"
FORMAT = "%(asctime)-15s %(name)-8s %(threadName)s %(levelname)s: %(message)s"
handler = logging.StreamHandler(sys.stdout)
handler.setLevel(logging.DEBUG)
handler.setFormatter(logging.Formatter(fmt=FORMAT))
Expand Down

0 comments on commit b39beec

Please sign in to comment.