logparse

package
v0.1.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package logparse provides functionality for parsing TF2 console logs into known events and values.

It should be able to parse logs from servers using SupStats2 & MedicStats plugins. These are the same requirements as logs.tf, so you should be able to download and parse them without much trouble.

Index

Constants

This section is empty.

Variables

View Source
var Weapons = map[PlayerClass][]Weapon{
	Multi: {
		ConscientiousObjector,
		FryingPan,
		HamShank,
		NecroSmasher,
		Pistol,
		ReserveShooter,
		Telefrag,
		World,
	},
	Scout: {
		Atomizer,
		Bat,
		ForceANature,
		PepPistol,
		PistolScout,
		Sandman,
		Scattergun,
		ShortStop,
		SodaPopper,
		WrapAssassin,
	},
	Soldier: {
		Airstrike,
		Blackbox,
		CowMangler,
		DirectHit,
		DisciplinaryAction,
		EscapePlan,
		LibertyLauncher,
		MarketGardener,
		Original,
		ProjectileRocket,
		ShotgunSoldier,
	},
	Pyro: {
		AiFlamethrower,
		Backburner,
		BackScratcher,
		DeflectPromode,
		DeflectRocket,
		Degreaser,
		Detonator,
		DragonsFury,
		DragonsFuryBonus,
		FlameThrower,
		FlareGun,
		HotHand,
		Maul,
		Phlog,
		Powerjack,
		Rainblower,
		ScorchShot,
		ShotgunPyro,
		Sledgehammer,
	},
	Demo: {
		Bottle,
		Caber,
		DemoKatana,
		IronBomber,
		LockNLoad,
		LooseCannon,
		LooseCannonImpact,
		ProjectilePipe,
		ProjectilePipeRemote,
		Quickiebomb,
		ScottishResistance,
	},
	Heavy: {
		BrassBeast,
		FamilyBusiness,
		Fists,
		FistsOfSteel,
		IronCurtain,
		LongHeatmaker,
		MiniGun,
		Natascha,
		Tomislav,
		WarriorsSpirit,
	},
	Engineer: {
		FrontierJustice,
		Gunslinger,
		GunslingerCombo,
		GunslingerTaunt,
		Jag,
		MiniSentry,
		RescueRanger,
		Sentry1,
		Sentry2,
		Sentry3,
		ShotgunPrimary,
		WidowMaker,
		Wrangler,
		Wrench,
	},
	Medic: {
		Amputator,
		Blutsauger,
		Bonesaw,
		Crossbow,
		ProtoSyringe,
		SyringeGun,
		TauntMedic,
		Ubersaw,
	},
	Sniper: {
		AwperHand,
		BazaarBargain,
		Bushwacka,
		Club,
		Huntsman,
		Kukri,
		Machina,
		MachinaPen,
		ProRifle,
		ProSMG,
		ShootingStar,
		SMG,
		SniperRifle,
		SydneySleeper,
		TheClassic,
	},
	Spy: {
		Ambassador,
		BigEarner,
		BlackRose,
		DiamondBack,
		Enforcer,
		EternalReward,
		Knife,
		Kunai,
		Letranger,
		Revolver,
		Sapper,
		SharpDresser,
		Spycicle,
	},
}

Functions

func NewPosFromString added in v0.1.8

func NewPosFromString(s string, p *Pos) error

func ParsePlayerClass added in v0.1.8

func ParsePlayerClass(classStr string, class *PlayerClass) bool

func ParseTeam added in v0.1.6

func ParseTeam(teamStr string, team *Team) bool

func Unmarshal added in v0.1.6

func Unmarshal(input interface{}, output interface{}) error

Unmarshal will transform a map of values into the struct passed in eg: {"sm_nextmap": "pl_frontier_final"} -> CVAREvt

Types

type BuiltObjectEvt

type BuiltObjectEvt CarryObjectEvt

type CVAREvt

type CVAREvt struct {
	CVAR  string `json:"cvar"`
	Value string `json:"value"`
	EmptyEvt
}

CVAREvt is emitted on a cvar change

type CaptureBlockedEvt

type CaptureBlockedEvt struct {
	EmptyEvt
	SourcePlayer
	CP     int    `json:"cp"`
	CPName string `json:"cp_name"`
	Pos    Pos    `json:"pos"`
}

type CarryObjectEvt

type CarryObjectEvt struct {
	EmptyEvt
	SourcePlayer
	Object string `json:"object"`
	Pos    Pos    `json:"a_pos"`
}

type ChangeClassEvt

type ChangeClassEvt struct {
	EmptyEvt
	Class PlayerClass `json:"class"`
}

type ChargeDeployedEvt

type ChargeDeployedEvt struct {
	EmptyEvt
	SourcePlayer
	Medigun Medigun `json:"medigun"`
}

type ChargeEndedEvt

type ChargeEndedEvt struct {
	EmptyEvt
	SourcePlayer
	Duration float32 `json:"duration"`
}

type ChargeReadyEvt

type ChargeReadyEvt struct {
	EmptyEvt
	SourcePlayer
}

type ConnectedEvt

type ConnectedEvt struct {
	EmptyEvt
	SourcePlayer
	Address string `json:"address"`
}

type DamageEvt

type DamageEvt struct {
	EmptyEvt
	SourcePlayer
	TargetPlayer
	Damage     int    `json:"damage"`
	RealDamage int    `json:"real_damage"`
	Weapon     Weapon `json:"weapon"`
	Healing    int    `json:"healing,omitempty"` // On ubersaw
}

type DisconnectedEvt

type DisconnectedEvt struct {
	EmptyEvt
	SourcePlayer
	Reason string `json:"reason"`
}

type DominationEvt

type DominationEvt struct {
	EmptyEvt
	SourcePlayer `json:"source"`
	TargetPlayer `json:"target"`
}

type DropObjectEvt

type DropObjectEvt CarryObjectEvt

type EmptyEvt

type EmptyEvt struct {
	CreatedOn time.Time `json:"created_on"`
}

EmptyEvt is the base event for all other events. It just contains a timestamp.

type EmptyUberEvt

type EmptyUberEvt struct {
	EmptyEvt
	SourcePlayer
}

type EnteredEvt

type EnteredEvt EmptyEvt

type FirstHealAfterSpawnEvt

type FirstHealAfterSpawnEvt struct {
	EmptyEvt
	SourcePlayer
	HealTime float32 `json:"time"`
}

type HealedEvt added in v0.1.8

type HealedEvt struct {
	EmptyEvt
	SourcePlayer
	TargetPlayer
	Healing int `json:"healing,omitempty"` // On ubersaw
}

type JoinedTeamEvt

type JoinedTeamEvt struct {
	EmptyEvt
	SourcePlayer
	Team Team `json:"team"`
}

type KillAssistEvt

type KillAssistEvt struct {
	EmptyEvt
	SourcePlayer
	TargetPlayer
	ASPos Pos `json:"as_pos"`
	APos  Pos `json:"a_pos"`
	VPos  Pos `json:"v_pos"`
}

type KilledEvt added in v0.1.8

type KilledEvt struct {
	EmptyEvt
	SourcePlayer
	TargetPlayer
	APos       Pos    `json:"attacker_position" mapstructure:"attacker_position"`
	VPos       Pos    `json:"victim_position" mapstructure:"victim_position"`
	Weapon     Weapon `json:"weapon" mapstructure:"weapon"`
	CustomKill string `json:"custom_kill"  mapstructure:"customkill"`
}

type KilledObjectEvt

type KilledObjectEvt struct {
	EmptyEvt
	SourcePlayer
	TargetPlayer
	Object string `json:"object"`
	Weapon Weapon `json:"weapon"`
	APos   Pos    `json:"a_pos"`
}

type LogStartEvt

type LogStartEvt struct {
	File    string `json:"file"`
	Game    string `json:"game"`
	Version string `json:"version"`
	EmptyEvt
}

type LogStopEvt

type LogStopEvt EmptyEvt

LogStopEvt is the server shutting down the map and closing the log

type LostUberAdvantageEvt

type LostUberAdvantageEvt struct {
	EmptyEvt
	SourcePlayer
	AdvTime int `json:"advtime"`
}

type MedicDeathEvt

type MedicDeathEvt struct {
	EmptyEvt
	SourcePlayer
	TargetPlayer
	Healing int `json:"healing"`
	Uber    int `json:"uber"`
}

type MedicDeathExEvt

type MedicDeathExEvt struct {
	UberPct int `json:"uber_pct"`
	EmptyEvt
}

type Medigun

type Medigun int

Medigun holds which medigun a player was using

const (
	Uber Medigun = iota
	Kritzkrieg
	Vaccinator
	QuickFix
)

type MsgType

type MsgType int

MsgType defines a known, parsable message type

const (
	// UnhandledMsg is used for messages we are ignoring
	UnhandledMsg MsgType = 0
	// UnknownMsg is for any unexpected message formats
	UnknownMsg MsgType = 1

	Say                 MsgType = 10
	SayTeam             MsgType = 11
	Killed              MsgType = 12
	KillAssist          MsgType = 13
	Suicide             MsgType = 14
	ShotFired           MsgType = 15
	ShotHit             MsgType = 16
	Damage              MsgType = 17
	Domination          MsgType = 18
	Revenge             MsgType = 19
	Pickup              MsgType = 20
	EmptyUber           MsgType = 21
	MedicDeath          MsgType = 22
	MedicDeathEx        MsgType = 23
	LostUberAdv         MsgType = 24
	ChargeReady         MsgType = 25
	ChargeDeployed      MsgType = 26
	ChargeEnded         MsgType = 27
	Healed              MsgType = 28
	Extinguished        MsgType = 29
	BuiltObject         MsgType = 30
	CarryObject         MsgType = 31
	KilledObject        MsgType = 32
	DetonatedObject     MsgType = 33
	DropObject          MsgType = 34
	FirstHealAfterSpawn MsgType = 35
	CaptureBlocked      MsgType = 36
	PointCaptured       MsgType = 48
	JoinedTeam          MsgType = 49
	ChangeClass         MsgType = 50
	SpawnedAs           MsgType = 51

	WRoundOvertime  MsgType = 100
	WRoundStart     MsgType = 101
	WRoundWin       MsgType = 102
	WRoundLen       MsgType = 103
	WTeamScore      MsgType = 104
	WTeamFinalScore MsgType = 105
	WGameOver       MsgType = 106
	WPaused         MsgType = 107
	WResumed        MsgType = 108

	LogStart     MsgType = 1000
	LogStop      MsgType = 1001
	CVAR         MsgType = 1002
	RCON         MsgType = 1003
	Connected    MsgType = 1004
	Disconnected MsgType = 1005
	Validated    MsgType = 1006
	Entered      MsgType = 1007

	Any MsgType = 10000
)

type PickupEvt

type PickupEvt struct {
	EmptyEvt
	SourcePlayer
	Item PickupItem
}

type PickupItem added in v0.1.8

type PickupItem int

PickupItem is used for

const (
	ItemHPSmall PickupItem = iota
	ItemHPMedium
	ItemHPLarge
	ItemAmmoSmall
	ItemAmmoMedium
	ItemAmmoLarge
)

type PlayerClass

type PlayerClass int
const (
	Spectator PlayerClass = 0
	Scout     PlayerClass = 1
	Soldier   PlayerClass = 2
	Pyro      PlayerClass = 3
	Demo      PlayerClass = 4
	Heavy     PlayerClass = 5
	Engineer  PlayerClass = 6
	Medic     PlayerClass = 7
	Sniper    PlayerClass = 8
	Spy       PlayerClass = 9
	Multi     PlayerClass = 10
)

type PointCapturedEvt

type PointCapturedEvt struct {
	Team       Team   `json:"team"`
	CP         int    `json:"cp"`
	CPName     string `json:"cp_name"`
	NumCappers int    `json:"num_cappers"`
	// TODO parse to player list
	Body string `json:"body"`
	EmptyEvt
}

type Pos

type Pos struct {
	X float64 `json:"x"`
	Y float64 `json:"y"`
	Z float64 `json:"z"`
}

Pos is a position in 3D space

func (*Pos) Encode added in v0.1.8

func (p *Pos) Encode() string

String returns a ST_MakePointM Uses ESPG 4326 (WSG-84)

type RCONEvt

type RCONEvt struct {
	Cmd string `json:"cmd"`
	EmptyEvt
}

RCONEvt is emitted on a rcon connection executing a command

type Results

type Results struct {
	MsgType MsgType
	Values  map[string]string
}

Results hold the results of parsing a log line

func Parse

func Parse(l string) Results

Parse will parse the log line into a known type and values

type RevengeEvt

type RevengeEvt DominationEvt

type SayEvt

type SayEvt struct {
	EmptyEvt
	SourcePlayer `json:"source"`
	Msg          string `json:"msg"`
}

type SayTeamEvt

type SayTeamEvt SayEvt

type ShotFiredEvt

type ShotFiredEvt struct {
	EmptyEvt
	SourcePlayer
	Weapon Weapon `json:"weapon"`
}

type ShotHitEvt

type ShotHitEvt struct {
	EmptyEvt
	SourcePlayer
	Weapon Weapon `json:"weapon"`
}

type SourcePlayer added in v0.1.6

type SourcePlayer struct {
	Name string        `json:"name"`
	PID  int           `json:"pid"`
	SID  steamid.SID64 `json:"sid"`
	Team Team          `json:"team"`
}

SourcePlayer represents the player who initiated the event

type SuicideEvt

type SuicideEvt struct {
	EmptyEvt
	SourcePlayer
	Pos Pos `json:"pos"`
}

type TargetPlayer

type TargetPlayer struct {
	Name2 string        `json:"name2"`
	PID2  int           `json:"pid2"`
	SID2  steamid.SID64 `json:"sid2"`
	Team2 Team          `json:"team2"`
}

TargetPlayer maps the common secondary player values name_2

type Team

type Team int

Team represents a players team, or spectator state

const (
	SPEC Team = 0
	RED  Team = 1
	BLU  Team = 2
)

type UnhandledMsgEvt

type UnhandledMsgEvt EmptyEvt

type WGameOverEvt

type WGameOverEvt struct {
	Reason string `json:"reason"`
	EmptyEvt
}

type WPausedEvt

type WPausedEvt EmptyEvt

type WResumedEvt

type WResumedEvt EmptyEvt

type WRoundLenEvt

type WRoundLenEvt struct {
	Length float64 `json:"length"`
	EmptyEvt
}

type WRoundOvertimeEvt

type WRoundOvertimeEvt EmptyEvt

type WRoundStartEvt

type WRoundStartEvt EmptyEvt

type WRoundWinEvt

type WRoundWinEvt struct {
	Winner Team `json:"winner"`
	EmptyEvt
}

type WTeamFinalScoreEvt

type WTeamFinalScoreEvt struct {
	Score   int `json:"score"`
	Players int `json:"players"`
	EmptyEvt
}

type WTeamScoreEvt

type WTeamScoreEvt struct {
	Team    Team `json:"team"`
	Score   int  `json:"score"`
	Players int  `json:"players"`
	EmptyEvt
}

type Weapon

type Weapon int
const (
	UnknownWeapon Weapon = iota
	AiFlamethrower
	Airstrike
	Ambassador
	Amputator
	Atomizer
	AwperHand
	Backburner
	BackScratcher
	Bat
	BazaarBargain
	BigEarner
	Blackbox
	BlackRose
	Blutsauger
	Bonesaw
	Bottle
	BrassBeast
	Bushwacka
	Caber
	Club
	ConscientiousObjector
	CowMangler
	Crossbow
	DeflectPromode
	DeflectRocket
	Degreaser
	DemoKatana
	Detonator
	DiamondBack
	DirectHit
	DisciplinaryAction
	DragonsFury
	DragonsFuryBonus
	Enforcer
	EscapePlan
	EternalReward
	FamilyBusiness
	Fists
	FistsOfSteel
	FlameThrower
	FlareGun
	ForceANature
	FrontierJustice
	FryingPan
	Gunslinger
	GunslingerCombo
	GunslingerTaunt
	HamShank
	HotHand
	Huntsman
	IronBomber
	IronCurtain
	Jag
	Knife
	Kukri
	Kunai
	Letranger
	LibertyLauncher
	LockNLoad
	LongHeatmaker
	LooseCannon
	LooseCannonImpact
	Machina
	MachinaPen
	MarketGardener
	Maul
	MiniGun
	MiniSentry
	Natascha
	NecroSmasher
	Original
	PepPistol
	Phlog
	Pistol
	PistolScout
	Powerjack
	ProjectilePipe
	ProjectilePipeRemote
	ProjectileRocket
	ProRifle
	ProSMG
	ProtoSyringe
	Quickiebomb
	Rainblower
	RescueRanger
	ReserveShooter
	Revolver
	Sandman
	Scattergun
	ScorchShot
	ScottishResistance
	Sentry1
	Sentry2
	Sentry3
	SharpDresser
	ShootingStar
	ShortStop
	ShotgunPrimary
	ShotgunPyro
	ShotgunSoldier
	Sledgehammer
	SMG
	SniperRifle
	SodaPopper
	Spycicle
	SydneySleeper
	SyringeGun
	TauntMedic
	Telefrag
	TheClassic
	Tomislav
	Ubersaw
	WarriorsSpirit
	WidowMaker
	World
	Wrangler
	WrapAssassin
	Wrench
	Sapper
)

func WeaponFromString added in v0.1.8

func WeaponFromString(s string) Weapon

func (Weapon) String added in v0.1.8

func (w Weapon) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL