Page 1 of 1

Error Message Inventory

PostPosted: Sun Jul 30, 2017 5:25 am
by DaveL17
Here is a simple Python script that will traverse the Indigo log folder tree and find all log lines with error messages. It places the result into a new file within the log folder called 'error_inventory.txt'.

Code: Select all
import os


check_list = [' Err ', ' err ', 'Error', 'error']
log_folder = indigo.server.getLogsFolderPath()

with open(log_folder + '/error_inventory.txt', 'w') as outfile:

    for root, sub, files in os.walk(log_folder):
        for filename in files:
            if filename.endswith((".log", ".txt")) and filename != 'error_inventory.txt':
                with open(os.path.join(root, filename), 'r') as infile:
                    log_file = infile.read()

                    for line in log_file.split("\n"):
                        if any(item in line for item in check_list):
                            outfile.write("{0:<130}{1}\n".format(root + filename, line))

indigo.server.log(u"Error Message Inventory saved to: {0}/error_inventory.txt".format(log_folder))
You can change the purpose of the search by changing the search terms in the check_list variable.

ETA: Modified to use convenience method to get logs folder path instead of install path.

Re: Error Message Inventory

PostPosted: Sun Jul 30, 2017 8:04 am
by howartp
Cool, very useful for finding all logs relating to a plugin


Sent from my iPhone using Tapatalk Pro

Re: Error Message Inventory

PostPosted: Sat Aug 05, 2017 5:39 am
by DaveL17
Adds minor simplification by using convenience method to get logs folder path instead of install path.