Skip to content

wankhede04/log-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

log-parser

log-parser is a Go based command-line software which helps to parse logs generated by Quake game.

Working

log-parser is run through cmd. So, one needs to provide command line flag to specify which file contains logs of Quake game. This can be done by proving it as a flag named log-file while running it. Example: When running from code directly

$ go run . --log-file=./test-parsing/log.log

or when running a build :

$ ./m --log-file=./test-parsing/log.log

This is a mandatory flag.

Game-Report

This is printed in console when above mentioned command is run, the data contains game-name, total-kills, ranks of players, total score of players. In the following format:

{
        "game_1": {
                "total_kills": 0,
                "kills": {
                }
                "ranks": {
                }
        },
        "game_2": {
                "total_kills": 11,
                "kills": {
                        "Isgalamido": -5
                }
                "ranks": {
                        "Isgalamido": 1
                }
        },
        "game_3": {
                "total_kills": 4,
                "kills": {
                        "Isgalamido": 1,
                        "Zeh": -2,
                        "Dono da Bola": -1
                }
                "ranks": {
                        "Isgalamido": 1
                        "Dono da Bola": 2
                        "Zeh": 3
                }
        },
        ...
}

Weapons Report(Plus Task)

Kills report is generated when the software is run. It contains reports of weapons presenting, how many kills were registered by a weapon in a particular game in json format. Example:

{
	"game_1": {
		"kills_by_means": {
		}
	},
	"game_2": {
		"kills_by_means": {
			"MOD_ROCKET_SPLASH": 3,
			"MOD_FALLING": 1,
			"MOD_TRIGGER_HURT": 7
		}
	},
	"game_3": {
		"kills_by_means": {
			"MOD_ROCKET": 1,
			"MOD_TRIGGER_HURT": 2,
			"MOD_FALLING": 1
		}
	},
	...
}

One can specify the file name along with its path to where it should be generated. This can be achieved by providing the filename as the flag named report-file. Example:

$ ./m --log-file=./test-parsing/log.log --report-file=./output.txt

Tests

The package also contains unit tests to ensure smooth working of software. These tests can be run by following command:

$ go test ./test-parsing/

It provides the following coverage of parse-log package:

ok      github.com/m/v2/test-parsing    0.003s  coverage: 91.1% of statements in ./parse-log/

Set-up

The following system can be set up by cloning this Repo:

$ git clone <link-to-repo>

and then to download dependencies:

$ go mod init

Pre-requisites

  • Go 1.20 or above

Regex used for parsing kill info

Visualization of the regex used can be found here: https://regexper.com/#Kill%3A%20%28%5Cd%2B%29%20%28%5Cd%2B%29%20%28%5Cd%2B%29%3A%20%28.%2B%3F%29%20killed%20%28.%2B%3F%29%20by%20%28%5B%5E%5Cn%5D%2B%29

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages