This project is a robust Quake 3 Arena log parser that processes game logs and generates detailed statistics. It's designed to handle large log files efficiently using Node.js streams, providing real-time data processing and analysis.
- Parses Quake 3 Arena log files;
- Generates detailed statistics for each game, including:
- Total kills;
- Player list;
- Individual player kills;
- Kills by means (weapons/methods).
- Streams results in real-time;
- Highly efficient, capable of handling large log files;
- Fully tested with comprehensive unit tests.
- Ensure you have Node.js installed on your system.
- Clone this repository:
git clone https://github.com/douglasdemoura/quake3-log-parser.git
- Navigate to the project directory:
cd quake3-log-parser
- Install dependencies:
npm install
import { GameStatistics } from "./lib/game-statistics.js";
import fs from "node:fs";
const gameStats = new GameStatistics("./src/database/qgames.txt");
const outputStream = fs.createWriteStream("./output.json");
let isFirstGame = true;
gameStats
.processLog()
.on("data", (chunk) => {
if (!isFirstGame) {
outputStream.write(",\n");
} else {
outputStream.write("[\n");
isFirstGame = false;
}
outputStream.write(chunk);
})
.on("end", () => {
// Write the closing bracket of the JSON array
outputStream.write("\n]");
outputStream.end();
console.log("Processing complete. Results written to output.json");
})
.on("error", (error) => {
console.error("Error processing log:", error);
});
The result will be written to output.json
file.
Run the comprehensive test suite with:
npm test
To generate a report, run the following command:
npm run generate-report
This will process the log file located at src/database/qgames.txt
, generate a JSON file with the statistics and print the results to the console.
new GameStatistics(logFilePath);
logFilePath
: Path to the Quake 3 Arena log file
processLog()
: Starts processing the log file and returns a readable stream;on('data', callback)
: Event emitted for each processed game;on('end', callback)
: Event emitted when log processing is complete;on('error', callback)
: Event emitted if an error occurs during processing;on('playerAdded', callback)
: Event emitted when a player is added to the current game being processed;on('gameAdded', callback)
: Event emitted when a game has been processed and added to the statistics;
quake-log-parser/
├── src/
│ ├── lib/
│ │ └── game-statistics.js
│ ├── database/
│ │ └── qgames.txt
│ └── index.js
├── tests/
│ └── lib/
│ └── game-statistics.test.js
├── package.json
└── README.md
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Quake 3 Arena for providing the inspiration and log format;
- Node.js for the powerful streaming capabilities.