Error Message Inventory

Posted on
Sun Jul 30, 2017 5:25 am
DaveL17 online
User avatar
Posts: 3298
Joined: Aug 20, 2013

Error Message Inventory

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.

Posted on
Sun Jul 30, 2017 8:04 am
howartp offline
Posts: 2800
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Error Message Inventory

Cool, very useful for finding all logs relating to a plugin


Sent from my iPhone using Tapatalk Pro

Posted on
Sat Aug 05, 2017 5:39 am
DaveL17 online
User avatar
Posts: 3298
Joined: Aug 20, 2013

Re: Error Message Inventory

Adds minor simplification by using convenience method to get logs folder path instead of install path.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest