log parser design question
avidfan
noone at nowhere.com
Sat Jan 27 23:43:10 EST 2007
I need to parse a log file using python and I need some advice/wisdom
on the best way to go about it:
The log file entries will consist of something like this:
ID=8688 IID=98889998 execute begin - 01.21.2007 status enabled
locked working.lock
status running
status complete
ID=9009 IID=87234785 execute wait - 01.21.2007 status wait
waiting to lock
status wait
waiting on ID=8688
and so on...
I need to be able to group these entries together, index them by ID
and IID, and search the context of each entry and if a certain status
if found (such as wait), then be able to return the ID or IID
(depending...) of that entry.
So I was considering parsing them to this effect:
in a dictionary, where the key is a tuple, and the value is a list:
{('ID=8688', 'IID=98889998'): ['ID=8688 IID=98889998 execute begin -
01.21.2007 status enabled', 'locked working.lock', 'status running',
'status complete']}
I am keeping the full text of each entry in the list so that I can
recreate them for display if need be.
I am fairly new to python, so could anyone offer any advice here
before I get too far and discover a fatal flaw that you might see
coming a mile away?
would I, with this design, be able to, for example, search each list
for "waiting on ID=8688", and when found, be able to associate that
value with one of the elements of it's key "ID=9009" ? or is this
approached flawed? I'm assuming there is a better way, but I need
some advice...
I appreciate any thoughts.
Thanks.
More information about the Python-list
mailing list