mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-24 16:08:11 +01:00
hookable log data debugging fixes
This commit is contained in:
parent
0d164e8f34
commit
7fd6361d30
3 changed files with 8 additions and 4 deletions
|
@ -42,9 +42,9 @@ class LogController:
|
||||||
except:
|
except:
|
||||||
self.logger.error("Failed to remove listener {}".format(listener_id))
|
self.logger.error("Failed to remove listener {}".format(listener_id))
|
||||||
|
|
||||||
async def _call_sensor_data_listeners(self, id, value, formatted_time, name):
|
async def _call_sensor_data_listeners(self, sensor_id, value, formatted_time, name):
|
||||||
for id, method in self.sensor_data_listeners.items():
|
for listener_id, method in self.sensor_data_listeners.items():
|
||||||
asyncio.create_task(method(self.cbpi, id, value, formatted_time, name))
|
asyncio.create_task(method(self.cbpi, sensor_id, value, formatted_time, name))
|
||||||
|
|
||||||
def log_data(self, id: str, value: str) -> None:
|
def log_data(self, id: str, value: str) -> None:
|
||||||
# all plugin targets:
|
# all plugin targets:
|
||||||
|
|
|
@ -42,7 +42,7 @@ class SensorLogTargetCSV(CBPiExtension):
|
||||||
data_logger = logging.getLogger('cbpi.sensor.%s' % id)
|
data_logger = logging.getLogger('cbpi.sensor.%s' % id)
|
||||||
data_logger.propagate = False
|
data_logger.propagate = False
|
||||||
data_logger.setLevel(logging.DEBUG)
|
data_logger.setLevel(logging.DEBUG)
|
||||||
handler = RotatingFileHandler(os.path.join(self.logsFolderPath, f"sensor_{id}.log"), maxBytes=max_bytes, backupCount=backup_count)
|
handler = RotatingFileHandler(os.path.join(self.cbpi.log.logsFolderPath, f"sensor_{id}.log"), maxBytes=max_bytes, backupCount=backup_count)
|
||||||
data_logger.addHandler(handler)
|
data_logger.addHandler(handler)
|
||||||
self.datalogger[id] = data_logger
|
self.datalogger[id] = data_logger
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,8 @@ class SensorLogTargetInfluxDB(CBPiExtension):
|
||||||
header = {'User-Agent': id, 'Authorization': "Token {}".format(self.influxdbpwd)}
|
header = {'User-Agent': id, 'Authorization': "Token {}".format(self.influxdbpwd)}
|
||||||
http = PoolManager(timeout=timeout)
|
http = PoolManager(timeout=timeout)
|
||||||
req = http.request('POST',self.influxdburl, body=out.encode(), headers = header)
|
req = http.request('POST',self.influxdburl, body=out.encode(), headers = header)
|
||||||
|
if req.status != 204:
|
||||||
|
raise Exception(f'InfluxDB Status code {req.status}')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error("InfluxDB cloud write Error: {}".format(e))
|
logging.error("InfluxDB cloud write Error: {}".format(e))
|
||||||
|
|
||||||
|
@ -72,6 +74,8 @@ class SensorLogTargetInfluxDB(CBPiExtension):
|
||||||
header = {'User-Agent': id, 'Content-Type': 'application/x-www-form-urlencoded','Authorization': 'Basic %s' % self.base64string.decode('utf-8')}
|
header = {'User-Agent': id, 'Content-Type': 'application/x-www-form-urlencoded','Authorization': 'Basic %s' % self.base64string.decode('utf-8')}
|
||||||
http = PoolManager(timeout=timeout)
|
http = PoolManager(timeout=timeout)
|
||||||
req = http.request('POST',self.influxdburl, body=out.encode(), headers = header)
|
req = http.request('POST',self.influxdburl, body=out.encode(), headers = header)
|
||||||
|
if req.status != 204:
|
||||||
|
raise Exception(f'InfluxDB Status code {req.status}')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error("InfluxDB write Error: {}".format(e))
|
logging.error("InfluxDB write Error: {}".format(e))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue