I'm writing a Python tool to parse a log file from game server. The log file is of format:


There are a lot of classes, and a lot of methods for each class, and each of them has its own format (number and meaning of arguments). I want to reconstruct the game (or at least relevant parts of it) from the log. I thought about doing something like this:

  • Creating a .format file where the formats of all the files are listed.
  • Each time I'll read the log, I'll analyze the format file, and create a dictionary of dictionaries - each class will have its own dictionary of methods, and the dictionary of each method would contain the args as a list. Then, each time I read a line, I'll check the dictionary for the format of the needed method of the needed class, and parse the line accordingly, and create some field-value dictionary structure to contain the information.

This seems reasonable, but I don't want to reinvent the wheel - I'm sure someone have thought about this already... Any smarter way to do it? Any shortcuts that could save me some work, or python tools that do something similar?

  • " I want to reconstruct the game (or at least relevant parts of it) from the log" - sounds like you have a long, hard, up-hill struggle ahead of you. Are you sure, before you start, that the logs will be sufficient? – Mawg Jan 8 '15 at 8:37
  • Yes, the game is not very complicated, and the log has all the information that passes in the game. What it does mean, that the format file has the potential to be long... that's why I wonder how to do it in a way that is not time-wasting for me. – Venomouse Jan 8 '15 at 11:35
  • Why do you need a format file? All the information about a method is already in the log (i.e. after ms:classname::id::.) That aside, the logs don't capture concepts like intermediate computations, return values, or scope, so I think you'll have a hard time extracting any logic from it that you can't already plainly see for yourself by looking at the logs. – Doval Jan 8 '15 at 17:20
  • There are different arguments for each method of each class (and the number of arguments changes too), so to understand what each number in line like 'class::id::method::1.4::-2.4::'John'', you need the function signature... Let's leave aside the question if I need the log analysis tool or not. Believe me that I do, when you need to analyze and plot the process of a lot of games, 'just looking' is not an option. – Venomouse Jan 9 '15 at 14:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.