Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
pipiche38 committed Nov 17, 2023
1 parent 1aed2e7 commit 29f787f
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 77,061 deletions.
64 changes: 31 additions & 33 deletions Classes/LoggingManagement.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ def logging(self, module, logType, message, nwkid=None, context=None):
else:
Domoticz.Log("%s" % message)


def _loggingStatus(self, thread_name, message):
if self.pluginconf.pluginConf["logThreadName"]:
message = "[%17s] " %thread_name + message
Expand Down Expand Up @@ -446,59 +445,58 @@ def start_logging_thread(self):
)
self.logging_thread.start()


def logging_thread(self):
""" logging thread """

Domoticz.Log("logging_thread - listening")
while self.running:
# We loop until self.running is set to False,
# which indicate plugin shutdown

logging_tuple = self.logging_queue.get()
if len(logging_tuple) == 2:
timing, command = logging_tuple
if command == "QUIT":
Domoticz.Log("logging_thread Exit requested")
break

if len(logging_tuple) == 2 and logging_tuple[1] == "QUIT":
Domoticz.Log("logging_thread Exit requested")
break

elif len(logging_tuple) == 8:
(
timing,
thread_name,
thread_id,
module,
logType,
message,
nwkid,
context,
) = logging_tuple
try:
context = eval(context)
except Exception as e:
Domoticz.Error("Something went wrong and catch: context: %s" % str(context))
Domoticz.Error(" logging_thread unexpected tuple %s" % (str(logging_tuple)))
Domoticz.Error(" Error %s" % (str(e)))
return
( timing, thread_name, thread_id, module, logType, message, nwkid, context, ) = logging_tuple

if context != str(None):
try:
context = eval(context)

except Exception as e:
Domoticz.Error("Something went wrong and catch: context: %s" % str(context))
Domoticz.Error(" logging_thread unexpected tuple %s" % (str(logging_tuple)))
Domoticz.Error(" Error %s" % (str(e)))
return

if logType == "Error":
loggingError(self, thread_name, module, message, nwkid, context)

elif logType == "Debug":
# thread filter
threadFilter = [
x for x in self.threadLogConfig if self.pluginconf.pluginConf["Thread" + self.threadLogConfig[x]] == 1
]
threadFilter = [ x for x in self.threadLogConfig if self.pluginconf.pluginConf["Thread" + self.threadLogConfig[x]] == 1 ]

if threadFilter and thread_name not in threadFilter:
continue

thread_name=thread_name + " " + thread_id
pluginConfModule = str(module)
if pluginConfModule in self.pluginconf.pluginConf:
if self.pluginconf.pluginConf[pluginConfModule]:
_logginfilter(self, thread_name, message, nwkid)
else:

if pluginConfModule in self.pluginconf.pluginConf and self.pluginconf.pluginConf[ pluginConfModule ]:
_logginfilter(self, thread_name, message, nwkid)

elif pluginConfModule not in self.pluginconf.pluginConf:
Domoticz.Error("%s debug module unknown %s" % (pluginConfModule, module))
_loggingDebug(self, thread_name, message)

else:
thread_name=thread_name + " " + thread_id
loggingDirector(self, thread_name, logType, message)

else:
Domoticz.Error("logging_thread unexpected tuple %s" % (str(logging_tuple)))

Domoticz.Log("logging_thread - ended")


Expand Down
24 changes: 21 additions & 3 deletions Classes/TransportStats.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,34 @@ def add_rxTiming(self, timing):
% (self._maxRxProcesses, self._averageRxProcess)
)

#def addPointforTrendStats(self, TimeStamp):
#
# MAX_TREND_STAT_TABLE = 120
#
# uptime = int(time() - self._start)
# Rxps = round(self._received / uptime, 2)
# Txps = round(self._sent / uptime, 2)
# if len(self.TrendStats) >= MAX_TREND_STAT_TABLE:
# del self.TrendStats[0]
# self.TrendStats.append({"_TS": TimeStamp, "Rxps": Rxps, "Txps": Txps, "Load": self._Load})

def addPointforTrendStats(self, TimeStamp):
""" Adds a data point to the trend statistics table. """

MAX_TREND_STAT_TABLE = 120

uptime = int(time() - self._start)
current_time = time()
uptime = int(current_time - self._start)
Rxps = round(self._received / uptime, 2)
Txps = round(self._sent / uptime, 2)

trend_stat = {"_TS": TimeStamp, "Rxps": Rxps, "Txps": Txps, "Load": self._Load}

if len(self.TrendStats) >= MAX_TREND_STAT_TABLE:
del self.TrendStats[0]
self.TrendStats.append({"_TS": TimeStamp, "Rxps": Rxps, "Txps": Txps, "Load": self._Load})
self.TrendStats = self.TrendStats[-MAX_TREND_STAT_TABLE + 1:]

self.TrendStats.append(trend_stat)


def reTx(self):
""" return the number of crc Errors """
Expand Down
Loading

0 comments on commit 29f787f

Please sign in to comment.