From 05dc80709e93669e016c6e2f9b32f0f886759e10 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Wed, 5 May 2021 17:32:07 +0200 Subject: [PATCH] Updating docs and logger --- miniconf.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/miniconf.py b/miniconf.py index 4878419..7f88f65 100644 --- a/miniconf.py +++ b/miniconf.py @@ -14,6 +14,7 @@ import uuid from gmqtt import Client as MqttClient +LOGGER = logging.getLogger(__name__) class Miniconf: """An asynchronous API for controlling Miniconf devices using MQTT.""" @@ -39,7 +40,6 @@ class Miniconf: self.inflight = {} self.client.on_message = self._handle_response self.client.subscribe(f'{prefix}/response/{self.uuid.hex}') - self.logger = logging.getLogger(__name__) def _handle_response(self, _client, _topic, payload, _qos, properties): """Callback function for when messages are received over MQTT. @@ -69,8 +69,7 @@ class Miniconf: value: The value to write to the path. Returns: - (code, msg) tuple as a response to the command. `code` is zero for success and `msg` is - a use-readable message indicating further information. + The response to the command as a dictionary. """ setting_topic = f'{self.prefix}/settings/{path}' response_topic = f'{self.prefix}/response/{self.uuid.hex}' @@ -85,7 +84,7 @@ class Miniconf: }).encode('ascii') value = json.dumps(value) - self.logger.info('Sending %s to "%s"', value, setting_topic) + LOGGER.info('Sending %s to "%s"', value, setting_topic) fut = asyncio.get_running_loop().create_future() self.inflight[request_id] = fut