From 61043afd988dde6306528ceaad4fc0e30d232720 Mon Sep 17 00:00:00 2001 From: Olivier Martin Date: Tue, 20 Feb 2024 23:25:39 +0100 Subject: [PATCH] gattlib-py: Use logger (instead of logging) --- gattlib-py/gattlib/device.py | 10 +++++----- gattlib-py/gattlib/mainloop.py | 5 +++-- gattlib-py/gattlib/uuid.py | 3 +-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gattlib-py/gattlib/device.py b/gattlib-py/gattlib/device.py index bb8f753c..df1b99a2 100644 --- a/gattlib-py/gattlib/device.py +++ b/gattlib-py/gattlib/device.py @@ -91,7 +91,7 @@ def on_connection(self, user_data: py_object): self.on_connection_callback(self, user_data) def on_connection_error(self, error: c_int, user_data: py_object): - logging.error("Failed to connect due to error '0x%x'", error) + logger.error("Failed to connect due to error '0x%x'", error) if self.on_connection_error_callback: self.on_connection_error_callback(self, error, user_data) @@ -140,7 +140,7 @@ def discover(self): service = GattService(self, _services[i]) self._services[service.short_uuid] = service - logging.debug("Service UUID:0x%x" % service.short_uuid) + logger.debug("Service UUID:0x%x" % service.short_uuid) # # Discover GATT Characteristics @@ -155,7 +155,7 @@ def discover(self): characteristic = GattCharacteristic(self, _characteristics[i]) self._characteristics[characteristic.short_uuid] = characteristic - logging.debug("Characteristic UUID:0x%x" % characteristic.short_uuid) + logger.debug("Characteristic UUID:0x%x" % characteristic.short_uuid) def get_advertisement_data(self): _advertisement_data = POINTER(GattlibAdvertisementData)() @@ -206,7 +206,7 @@ def get_advertisement_data(self): @property def services(self): if not hasattr(self, '_services'): - logging.warning("Start GATT discovery implicitly") + logger.warning("Start GATT discovery implicitly") self.discover() return self._services @@ -214,7 +214,7 @@ def services(self): @property def characteristics(self): if not hasattr(self, '_characteristics'): - logging.warning("Start GATT discovery implicitly") + logger.warning("Start GATT discovery implicitly") self.discover() return self._characteristics diff --git a/gattlib-py/gattlib/mainloop.py b/gattlib-py/gattlib/mainloop.py index 08c84b29..33703097 100644 --- a/gattlib-py/gattlib/mainloop.py +++ b/gattlib-py/gattlib/mainloop.py @@ -4,7 +4,6 @@ # Copyright (c) 2016-2024, Olivier Martin # -import logging import threading import time import traceback @@ -12,6 +11,8 @@ #import dbus.mainloop.glib from gi.repository import GObject +from . import logger + gobject_mainloop: GObject.MainLoop = None task_returned_code: int = -1 task_exception: Exception = None @@ -32,7 +33,7 @@ def _user_thread_main(task): # Run user's code. task_returned_code = task() except Exception as ex: - logging.error("Exception in %s: %s: %s", task, type(ex), str(ex)) + logger.error("Exception in %s: %s: %s", task, type(ex), str(ex)) traceback.print_exception(type(ex), ex, ex.__traceback__) task_exception = ex finally: diff --git a/gattlib-py/gattlib/uuid.py b/gattlib-py/gattlib/uuid.py index d40f458d..b1411ff6 100644 --- a/gattlib-py/gattlib/uuid.py +++ b/gattlib-py/gattlib/uuid.py @@ -4,7 +4,6 @@ # Copyright (c) 2016-2024, Olivier Martin # -import logging import re from uuid import UUID @@ -54,5 +53,5 @@ def gattlib_uuid_str_to_int(uuid_str: str) -> int: try: return UUID(uuid_str).int except ValueError: - logging.error("Could not convert %s to a UUID", uuid_str) + logger.error("Could not convert %s to a UUID", uuid_str) raise