Skip to content

Commit 1c69607

Browse files
committed
mqtt: api: rename DeviceLogSeverity => LogSeverity
1 parent a22d663 commit 1c69607

File tree

4 files changed

+16
-20
lines changed

4 files changed

+16
-20
lines changed

enapter/mqtt/api/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
from .command import CommandRequest, CommandResponse, CommandState
2-
from .device_channel import DeviceChannel, DeviceLogSeverity
2+
from .device_channel import DeviceChannel
3+
from .log_severity import LogSeverity
34

45
__all__ = [
56
"CommandRequest",
67
"CommandResponse",
78
"CommandState",
89
"DeviceChannel",
9-
"DeviceLogSeverity",
10+
"LogSeverity",
1011
]

enapter/mqtt/api/device_channel.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import enum
21
import json
32
import logging
43
import time
@@ -73,10 +72,3 @@ async def _publish(self, path, payload, **kwargs):
7372
await self._client.publish(topic, payload, **kwargs)
7473
except Exception as e:
7574
self._logger.error("failed to publish %s: %r", path, e)
76-
77-
78-
class DeviceLogSeverity(enum.Enum):
79-
DEBUG = "debug"
80-
INFO = "info"
81-
WARNING = "warning"
82-
ERROR = "error"

enapter/mqtt/api/log_severity.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import enum
2+
3+
4+
class LogSeverity(enum.Enum):
5+
DEBUG = "debug"
6+
INFO = "info"
7+
WARNING = "warning"
8+
ERROR = "error"

enapter/vucm/logger.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,27 @@ def _new_logger(hardware_id, channel_id):
1818
async def debug(self, msg: str, persist: bool = False):
1919
self._logger.debug(msg)
2020
await self.log(
21-
msg, severity=enapter.mqtt.api.DeviceLogSeverity.DEBUG, persist=persist
21+
msg, severity=enapter.mqtt.api.LogSeverity.DEBUG, persist=persist
2222
)
2323

2424
async def info(self, msg: str, persist: bool = False):
2525
self._logger.info(msg)
26-
await self.log(
27-
msg, severity=enapter.mqtt.api.DeviceLogSeverity.INFO, persist=persist
28-
)
26+
await self.log(msg, severity=enapter.mqtt.api.LogSeverity.INFO, persist=persist)
2927

3028
async def warning(self, msg: str, persist: bool = False):
3129
self._logger.warning(msg)
3230
await self.log(
33-
msg, severity=enapter.mqtt.api.DeviceLogSeverity.WARNING, persist=persist
31+
msg, severity=enapter.mqtt.api.LogSeverity.WARNING, persist=persist
3432
)
3533

3634
async def error(self, msg: str, persist: bool = False):
3735
self._logger.error(msg)
3836
await self.log(
39-
msg, severity=enapter.mqtt.api.DeviceLogSeverity.ERROR, persist=persist
37+
msg, severity=enapter.mqtt.api.LogSeverity.ERROR, persist=persist
4038
)
4139

4240
async def log(
43-
self,
44-
msg: str,
45-
severity: enapter.mqtt.api.DeviceLogSeverity,
46-
persist: bool = False,
41+
self, msg: str, severity: enapter.mqtt.api.LogSeverity, persist: bool = False
4742
):
4843
await self._channel.publish_logs(msg=msg, severity=severity, persist=persist)
4944

0 commit comments

Comments
 (0)