-
Notifications
You must be signed in to change notification settings - Fork 20
SourceLog
This class will implement the Source Server Log protocol as specified here: HL_Log_Standard
The purpose of this class is the ability to parse Source Server logs, either from physical files on disk, or in real time as received via UDP (see the server command ‘logadress’). The latter will give you the ability to react to certain events on the gameserver without actually writing a plugin.
Parsing Source log files is a wonky business. Although the general format is described in the Wiki, there really is no standard. Every game does it differently, and there always are some messages that do not fit in the grand scheme, and because strings are not escaped at all, players can break the format with funny names.
For this reason, the SourceLogParser class tries to do full line matching using RegExp. This currently works well for Team Fortress 2, for other games, you may have to add additional matching rules. The matching rules are kept in a list so it can be extended at run time without changing code.
When a line matches a rule, the action function is called with the timestamp of the log entry, name of the rule, a dict with values, and a dict with properties. This way you can access the data of the log message in Python data structure and react to it.