Outputting information from the plugin log
Posted: Wed May 16, 2018 7:03 am
Is it dangerous to offer a menu item that reads the plugin log and outputs certain lines to the Event Log? I was just thinking that this could result in an infinite loop depending on how Indigo handled the logging.
It would be a very limited set of lines, I wanted to offer an easy way for the user to see a list of results that the plugin takes over a period of time, and would be hard to see just traversing their event log.
Code:
It would be a very limited set of lines, I wanted to offer an easy way for the user to see a list of results that the plugin takes over a period of time, and would be hard to see just traversing their event log.
Code:
- Code: Select all
try:
indigo.server.log("Listing filter block log records:")
for filename in os.listdir(self.LogFileLoc):
log_file = open(self.LogFileLoc + filename, "r")
for line in log_file.readlines():
if "Filter block:" in line or "will not" in line: # "will not is legacy, will be depreciated"
indigo.server.log(line)
indigo.server.log("completed log output")
except Exception as e:
self.logger.error("An error occured while reading the filter log: " + str(e))