Skip to content

Add StreamHandler to logger #50

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

Merged
merged 3 commits into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion adafruit_azureiot/device_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ def __init__(
self._id_scope = id_scope
self._device_id = device_id
self._device_sas_key = device_sas_key
self._logger = logger if logger is not None else logging.getLogger("log")
if logger is not None:
self._logger = logger
else:
self._logger = logging.getLogger("log")
self._logger.addHandler(logging.StreamHandler())

self._mqtt = None
self._auth_response_received = False
Expand Down
6 changes: 5 additions & 1 deletion adafruit_azureiot/iot_mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,11 @@ def __init__(
self._hostname, device_id, constants.IOTC_API_VERSION
)
self._passwd = self._gen_sas_token()
self._logger = logger if logger is not None else logging.getLogger("log")
if logger is not None:
self._logger = logger
else:
self._logger = logging.getLogger("log")
self._logger.addHandler(logging.StreamHandler())
self._is_subscribed_to_twins = False

def _subscribe_to_core_topics(self):
Expand Down
6 changes: 5 additions & 1 deletion adafruit_azureiot/iotcentral_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ def __init__(
self._device_id = device_id
self._device_sas_key = device_sas_key
self._token_expires = token_expires
self._logger = logger if logger is not None else logging.getLogger("log")
if logger is not None:
self._logger = logger
else:
self._logger = logging.getLogger("log")
self._logger.addHandler(logging.StreamHandler())
self._device_registration = None
self._mqtt = None

Expand Down
7 changes: 5 additions & 2 deletions adafruit_azureiot/iothub_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,11 @@ def __init__(
self._socket = socket
self._iface = iface
self._token_expires = token_expires
self._logger = logger if logger is not None else logging.getLogger("log")

if logger is not None:
self._logger = logger
else:
self._logger = logging.getLogger("log")
self._logger.addHandler(logging.StreamHandler())
connection_string_values = {}

try:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

Adafruit-Blinka
Adafruit-CircuitPython-miniMQTT
Adafruit-CircuitPython-Logging
Adafruit-CircuitPython-Logging>=4.0.1
Adafruit-CircuitPython-Requests
Adafruit-CircuitPython-Binascii
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
install_requires=[
"Adafruit-Blinka",
"Adafruit-CircuitPython-miniMQTT",
"Adafruit-CircuitPython-Logging",
"Adafruit-CircuitPython-Logging>=4.0.1",
"Adafruit-CircuitPython-Requests",
"Adafruit-CircuitPython-Binascii",
],
Expand Down