mirror of https://github.com/labapart/gattlib
gattlib-py: Use logger (instead of logging)
parent
aacc53c511
commit
61043afd98
|
@ -91,7 +91,7 @@ class Device:
|
|||
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 @@ class Device:
|
|||
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 @@ class Device:
|
|||
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 @@ class Device:
|
|||
@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 @@ class Device:
|
|||
@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
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
# Copyright (c) 2016-2024, Olivier Martin <olivier@labapart.org>
|
||||
#
|
||||
|
||||
import logging
|
||||
import threading
|
||||
import time
|
||||
import traceback
|
||||
|
@ -12,6 +11,8 @@ import traceback
|
|||
#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:
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
# Copyright (c) 2016-2024, Olivier Martin <olivier@labapart.org>
|
||||
#
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue