From 41d9a2a1ef3040b4805b053db625a1a37007865f Mon Sep 17 00:00:00 2001 From: Stefan Allius Date: Thu, 9 May 2024 14:19:37 +0200 Subject: [PATCH] improve logger --- app/src/gen3plus/infos_g3p.py | 5 +++-- app/src/modbus.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/gen3plus/infos_g3p.py b/app/src/gen3plus/infos_g3p.py index ed8d9bd..a436dbf 100644 --- a/app/src/gen3plus/infos_g3p.py +++ b/app/src/gen3plus/infos_g3p.py @@ -88,7 +88,7 @@ class InfosG3P(Infos): if res: yield res - def parse(self, buf, msg_type: int, rcv_ftype: int) \ + def parse(self, buf, msg_type: int, rcv_ftype: int, node_id: str = '') \ -> Generator[tuple[str, bool], None, None]: '''parse a data sequence received from the inverter and stores the values in Infos.db @@ -123,4 +123,5 @@ class InfosG3P(Infos): update = False if update: - self.tracer.log(level, f'GEN3PLUS: {name} : {result}{unit}') + self.tracer.log(level, f'[\'{node_id}\']GEN3PLUS: {name}' + f' : {result}{unit}') diff --git a/app/src/modbus.py b/app/src/modbus.py index c69dbb9..0047afc 100644 --- a/app/src/modbus.py +++ b/app/src/modbus.py @@ -142,7 +142,7 @@ class Modbus(): yield keys[0], update, result if update: info_db.tracer.log(level, - f'MODBUS[{node_id}]: {name}' + f'[\'{node_id}\']MODBUS: {name}' f' : {result}{unit}') def check_crc(self, msg) -> bool: