log_loop

package
v0.0.0-...-d73579a Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActionKill         = "KILL"
	ActionConnected    = "CONNECTED"
	ActionDisconnected = "DISCONNECTED"
	ActionChat         = "CHAT"
	ActionMatchStart   = "MATCH START"
	ActionMatchEnded   = "MATCH ENDED"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type LogLoop

type LogLoop struct {
	// contains filtered or unexported fields
}

func NewLogLoop

func NewLogLoop(opts LogLoopOptions) *LogLoop

NewLogLoop instantiates a log loop, which periodically requests logs from the game server, parses them and exposes them in batches to the caller.

Not all events are currently parsed, however, each log line is added to the batches at least with the raw message.

func (*LogLoop) Run

func (l *LogLoop) Run(ctx context.Context, f func(l []StructuredLogLine) bool) error

Run starts polling logs from the server. Each time at least one new log line is discovered, the passed function f is called with an undefined number of log lines as it's only argument. Whenever f is called, at least one log line will be in the log line slice.

The return value of f is a boolean indicating if polling for new log lines should continue. Returning true will stop this run with no error. Polling can be restarted by calling Run again. Returning false will result in Run to continue polling for new log lines.

type LogLoopOptions

type LogLoopOptions struct {
	Logger            *slog.Logger
	Pool              RConPool
	InitialLogMinutes *int
}

type MatchResult

type MatchResult struct {
	Axis   int
	Allied int
}

type Player

type Player struct {
	Name      string
	SteamId64 string
	Team      string
}

type RConPool

type RConPool interface {
	WithConnection(ctx context.Context, f func(c *rcon.Connection) error) error
}

type StructuredLogLine

type StructuredLogLine struct {
	Raw       string
	Timestamp time.Time
	Action    string
	Actor     Player
	Subject   Player
	Weapon    string
	Message   string
	Result    *MatchResult
	Rest      string
}

func ParseLogLine

func ParseLogLine(line string) (StructuredLogLine, error)

func (*StructuredLogLine) String

func (l *StructuredLogLine) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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