Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logging: Simplify imports and initialization #2257

Merged
merged 4 commits into from
Feb 10, 2024
Merged

logging: Simplify imports and initialization #2257

merged 4 commits into from
Feb 10, 2024

Conversation

MattHag
Copy link
Collaborator

@MattHag MattHag commented Feb 10, 2024

Fixes #2254

@pfps
Copy link
Collaborator

pfps commented Feb 10, 2024

I get errors in this PR

idefix Solaar> bin/solaar -d
2024-02-10 09:38:06,812,812    ERROR [MainThread] logitech_receiver.diversion: failed to load from /home/pfps/.config/solaar/rules.yaml
'>=' not supported between instances of 'int' and 'function'
2024-02-10 09:38:07,008,008  WARNING [MainThread] hidapi.udev: Report Descriptor not processed for DEVICE /dev/hidraw6 BID 001F VID 00008087 PID 00000AC2: unpack requires a buffer of 2 bytes
2024-02-10 09:38:07,008,008  WARNING [MainThread] hidapi.udev: Report Descriptor not processed for DEVICE /dev/hidraw7 BID 001F VID 00008087 PID 00000AC2: unpack requires a buffer of 2 bytes
2024-02-10 09:38:07,021,021  WARNING [MainThread] hidapi.udev: Report Descriptor not processed for DEVICE /dev/hidraw4 BID 0018 VID 0000056A PID 000051E3: Unsupported global tag: 0b101
2024-02-10 09:38:07,022,022  WARNING [MainThread] hidapi.udev: Report Descriptor not processed for DEVICE /dev/hidraw2 BID 0018 VID 000006CB PID 0000CD3E: Unsupported global tag: 0b101
2024-02-10 09:38:07,129,129    ERROR [ReceiverListener:hidraw5] logitech_receiver.listener: processing Notification(10,1,41,0C,327F40)
Traceback (most recent call last):
  File "/usr/lib64/python3.12/logging/__init__.py", line 1798, in isEnabledFor
    return self._cache[level]
           ~~~~~~~~~~~^^^^^^^
KeyError: <function debug at 0x7f6eadd2c040>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/local/SoftwareDownloads/Solaar/lib/logitech_receiver/listener.py", line 176, in run
    self._notifications_callback(n)
  File "/home/local/SoftwareDownloads/Solaar/lib/solaar/listener.py", line 276, in _notifications_handler
    _notifications.process(dev, n)
  File "/home/local/SoftwareDownloads/Solaar/lib/logitech_receiver/notifications.py", line 58, in process
    return _process_device_notification(device, status, notification)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/local/SoftwareDownloads/Solaar/lib/logitech_receiver/notifications.py", line 176, in _process_device_notification
    return _process_hidpp10_notification(device, status, n)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/local/SoftwareDownloads/Solaar/lib/logitech_receiver/notifications.py", line 286, in _process_hidpp10_notification
    status.changed(active=link_established)
  File "/home/local/SoftwareDownloads/Solaar/lib/logitech_receiver/status.py", line 281, in changed
    self.read_battery(timestamp)
  File "/home/local/SoftwareDownloads/Solaar/lib/logitech_receiver/status.py", line 250, in read_battery
    battery = self._device.battery()
              ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/local/SoftwareDownloads/Solaar/lib/logitech_receiver/device.py", line 400, in battery
    result = _hidpp20.get_battery(self, battery_feature)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/local/SoftwareDownloads/Solaar/lib/logitech_receiver/hidpp20.py", line 1852, in get_battery
    result = battery_function(device)
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/local/SoftwareDownloads/Solaar/lib/logitech_receiver/hidpp20.py", line 1776, in get_battery_voltage
    return decipher_battery_voltage(report)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/local/SoftwareDownloads/Solaar/lib/logitech_receiver/hidpp20.py", line 1804, in decipher_battery_voltage
    if logger.isEnabledFor(logging.debug):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/logging/__init__.py", line 1802, in isEnabledFor
    if self.manager.disable >= level:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: '>=' not supported between instances of 'int' and 'function'

@pfps
Copy link
Collaborator

pfps commented Feb 10, 2024

@MattHag See previous comment about errors.

@MattHag
Copy link
Collaborator Author

MattHag commented Feb 10, 2024

I see my mistake, used the wrong capitalization for some replacements.

@@ -117,7 +114,7 @@ def _parse_arguments():
logging.getLogger('').addHandler(stream_handler)

if not args.action:
if _log.isEnabledFor(logging.INFO):
if logger.isEnabledFor(logging.INFO):
logging.info('version %s, language %s (%s)', __version__, _i18n.language, _i18n.encoding)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be logger.info as well?

@pfps
Copy link
Collaborator

pfps commented Feb 10, 2024

@MattHag Yes.

Copy link
Collaborator

@pfps pfps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now

@pfps pfps merged commit 87658fb into pwr-Solaar:master Feb 10, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clean up common logging code
2 participants