I have a Python log file (let's call it logfile.log
) with a bunch of Python errors. There's one particular error being caused by several different methods (let's call it blah blah error
). The entries look something like this:
CRITICAL - Unexpected Error: blah blah error
Traceback (most recent call last):
File "example1.py", line 100, in method1
File "example2.py", line 200, in method2
File "example3.py", line 300, in method3
pythonerror.Error: blah blah error
In the sample above, the source of the error - method3
- can be several different methods. I want to go through the entire log file and count how many times each method appears in one of these errors, if it appears at all. Is this possible using regex? What would I need to do to accomplish this?
NOTE: The log file doesn't only contain this particular error, so the method might appear in other errors. I want to get the count of it only if it's within that particular error and only if it's the source of the error (second to last line in the above example).