Skip to content

Commit feb6fd1

Browse files
authored
Merge pull request #50 from tekktrik/dev/logging-changes
Add StreamHandler to logger
2 parents 8204fd4 + 603d269 commit feb6fd1

File tree

6 files changed

+22
-7
lines changed

6 files changed

+22
-7
lines changed

adafruit_azureiot/device_registration.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ def __init__(
6363
self._id_scope = id_scope
6464
self._device_id = device_id
6565
self._device_sas_key = device_sas_key
66-
self._logger = logger if logger is not None else logging.getLogger("log")
66+
if logger is not None:
67+
self._logger = logger
68+
else:
69+
self._logger = logging.getLogger("log")
70+
self._logger.addHandler(logging.StreamHandler())
6771

6872
self._mqtt = None
6973
self._auth_response_received = False

adafruit_azureiot/iot_mqtt.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,11 @@ def __init__(
353353
self._hostname, device_id, constants.IOTC_API_VERSION
354354
)
355355
self._passwd = self._gen_sas_token()
356-
self._logger = logger if logger is not None else logging.getLogger("log")
356+
if logger is not None:
357+
self._logger = logger
358+
else:
359+
self._logger = logging.getLogger("log")
360+
self._logger.addHandler(logging.StreamHandler())
357361
self._is_subscribed_to_twins = False
358362

359363
def _subscribe_to_core_topics(self):

adafruit_azureiot/iotcentral_device.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@ def __init__(
111111
self._device_id = device_id
112112
self._device_sas_key = device_sas_key
113113
self._token_expires = token_expires
114-
self._logger = logger if logger is not None else logging.getLogger("log")
114+
if logger is not None:
115+
self._logger = logger
116+
else:
117+
self._logger = logging.getLogger("log")
118+
self._logger.addHandler(logging.StreamHandler())
115119
self._device_registration = None
116120
self._mqtt = None
117121

adafruit_azureiot/iothub_device.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,11 @@ def __init__(
154154
self._socket = socket
155155
self._iface = iface
156156
self._token_expires = token_expires
157-
self._logger = logger if logger is not None else logging.getLogger("log")
158-
157+
if logger is not None:
158+
self._logger = logger
159+
else:
160+
self._logger = logging.getLogger("log")
161+
self._logger.addHandler(logging.StreamHandler())
159162
connection_string_values = {}
160163

161164
try:

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44

55
Adafruit-Blinka
66
Adafruit-CircuitPython-miniMQTT
7-
Adafruit-CircuitPython-Logging
7+
Adafruit-CircuitPython-Logging>=4.0.1
88
Adafruit-CircuitPython-Requests
99
Adafruit-CircuitPython-Binascii

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
install_requires=[
3737
"Adafruit-Blinka",
3838
"Adafruit-CircuitPython-miniMQTT",
39-
"Adafruit-CircuitPython-Logging",
39+
"Adafruit-CircuitPython-Logging>=4.0.1",
4040
"Adafruit-CircuitPython-Requests",
4141
"Adafruit-CircuitPython-Binascii",
4242
],

0 commit comments

Comments
 (0)