Skip to content

Commit

Permalink
gattlib-py: Use logger (instead of logging)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviermartin committed Feb 20, 2024
1 parent aacc53c commit 61043af
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions gattlib-py/gattlib/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand All @@ -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)()
Expand Down Expand Up @@ -206,15 +206,15 @@ 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

@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
Expand Down
5 changes: 3 additions & 2 deletions gattlib-py/gattlib/mainloop.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
# Copyright (c) 2016-2024, Olivier Martin <olivier@labapart.org>
#

import logging
import threading
import time
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
Expand All @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions gattlib-py/gattlib/uuid.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# Copyright (c) 2016-2024, Olivier Martin <olivier@labapart.org>
#

import logging
import re
from uuid import UUID

Expand Down Expand Up @@ -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

0 comments on commit 61043af

Please sign in to comment.