A PHP script that parses client's console logs from matches in KTX mods and extracts player stats from them into PHP array structures (XML or JSON supported too). It's suitable for leagues to offer rich detailed match statistics on their webpages, much more than just frag amounts.
Benefits:
Visit this page to see .log files and the results of their parsing
Upload your console log here and the script will produce a HTML page with stats preview.
Clients need to set following settings:
match_auto_logconsole 2
That will make client automatically log console text during the match, which is exactly what this script parses. If user forgot to enable console logging, he can create the log later from the demo! Launch the demo playback and then write following into the console:
log mylog; demo_jump 30:00; log stop
You don't have to start logging from the exact start of the demo, so no need to rush :).
FuhQuake users reported issues with the demo_jump command. If you have such problems too, use demo_setspeed 10000000 instead of demo_jump and do the log stop
after the demo is over
A .log file like this or this will get saved in users quake/log dir, from where it can be uploaded to your website. Then is the time for this script to take some action - you use it to read the contents of the log. It's up to you which stats you'll print in what form, this script just gives you the raw data.
How to actually use this script.
First of all, let your visitors upload the log files to some directory on your web server.
This is up to you to handle, the script will not help you with that.
Then you need to create a page page where you will call this script to display contents of the logs in nice structured HTML.
require_once "ktlogpsr.php";
$logParser = new KTLogParser;
$logData = $logParser->Parse("a.log", "fragfile.dat");
Replace "a.log" with the log that you want to parse. fragfile.dat
is a file describing the
format of frag messages in QuakeWorld. You can find this file in our source code repository too.
$logVisualiser = new KTLP_Visualizer;
echo $logVisualiser->GetHtml($logData);
echo $logVisualiser->GetMiniHtml($logData);
$logVisualiser->setRenameStats(true);
$logParser->GetArray(); // this is the same as the result of $logParser->Parse(..) call
$logParser->GetXML();
$logParser->GetJSON();
Parsing of the log file is an expensive process. You may want to cache the results of parsing to increase the load time of the pages with stats and to decrease your web server CPU usage.
It is recommended to cache the result of $logParser->Parse(..) call using e.g. PHP inbuilt function serialize(). You can take benefit of other existing PHP functions too, so you get something like:
$logData = unserialize(file_get_contents("logs/cached_{$log_id}.dat"));
This is all up to you to handle on your site. When testing effects of caching, load time of a single page with stats got reduced from ~500 ms down to ~90 ms.
KT Log Parser Project - repository