Skip to content

Commit

Permalink
ui: be more cautious when creating log messages to avoid exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
pfps committed Nov 18, 2023
1 parent a7d2e99 commit 1450e7e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/solaar/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,12 @@ def _status_changed(self, device, alert=_status.ALERT.NONE, reason=None):
if _log.isEnabledFor(_INFO):
if device.kind is None:
_log.info(
'status_changed %s: %s, %s (%X) %s', device, 'present' if bool(device) else 'removed', device.status,
'status_changed %r: %s, %s (%X) %s', device, 'present' if bool(device) else 'removed', device.status,
alert, reason or ''
)
else:
_log.info(
'status_changed %s: %s %s, %s (%X) %s', device, 'paired' if bool(device) else 'unpaired',
'status_changed %r: %s %s, %s (%X) %s', device, 'paired' if bool(device) else 'unpaired',
'online' if device.online else 'offline', device.status, alert, reason or ''
)

Expand Down Expand Up @@ -253,7 +253,7 @@ def _notifications_handler(self, n):
# Apply settings every time the device connects
if n.sub_id == 0x41:
if _log.isEnabledFor(_INFO):
_log.info('connection %s for %s (%s)', n, dev, dev.kind)
_log.info('connection %s for %r', n, dev)
# If there are saved configs, bring the device's settings up-to-date.
# They will be applied when the device is marked as online.
configuration.attach_to(dev)
Expand Down

0 comments on commit 1450e7e

Please sign in to comment.