logs

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: May 27, 2025 License: MIT Imports: 10 Imported by: 0

README

SquadRcon

This library is designed for the game Squad, it will give you the ability to easily parse game logs. It is possible to read the file locally or protocol SFTP. I hope this will be useful to you!

Install

go get -u github.com/SquadGO/squad-logs-go

Quick start example

import (
  "fmt"
  logs "github.com/SquadGO/squad-logs-go"
  "github.com/SquadGO/squad-logs-go/logsEvents"
  "github.com/SquadGO/squad-logs-go/logsTypes"
)

func main() {
  fr, err := logs.NewFTPReader(
    logs.FTPReaderConfig{
      Host:               "127.0.0.1:22",
      Username:           "root",
      Password:           "password",
      LogPath:            "/server/SquadGame.log",
      AdminsPath:         "/server/Admins.cfg", // TODO
      AutoReconnect:      true,
      AutoReconnectDelay: 5,
    },
  )

  if err != nil {
    fmt.Println("[LOGS] Error: ", err)
    return
  }

  defer fr.Close()

  fmt.Println("[LOGS] Connection successful")

  /* Listeners works after first initialization */

  fr.Emitter.On(logsEvents.CONNECTED, func(_ interface{}) {
    fmt.Println("[LOGS] Connection successful")
  })

  fr.Emitter.On(logsEvents.RECONNECTING, func(i interface{}) {
    fmt.Println("[LOGS] Reconnecting")
  })

  fr.Emitter.On(logsEvents.CLOSE, func(_ interface{}) {
    fmt.Println("[LOGS] Connection closed")
  })

  fr.Emitter.On(logsEvents.ERROR, func(err interface{}) {
    fmt.Println("[LOGS] Error: ", err)
  })

  fr.Emitter.On(logsEvents.PLAYER_DAMAGED, func(i interface{}) {
    if data, ok := i.(logsTypes.PlayerDamaged); ok {
      fmt.Println(data)
    }
  })

  // Use to prevent the program from ending
  select {}
}

Listeners

Listeners Returns
CONNECTED nil
RECONNECTING nil
CLOSE nil
ERROR Error
ADMIN_BROADCAST AdminBroadcast
DEPLOYABLE_DAMAGED DeployableDamaged
NEW_GAME NewGame
PLAYER_CONNECTED PlayerConnected
PLAYER_DISCONNECTED PlayerDisconnected
PLAYER_DAMAGED PlayerDamaged
PLAYER_DIED PlayerDied
PLAYER_POSSESS PlayerPossess
PLAYER_UNPOSSESS PlayerUnpossess
PLAYER_REVIVED PlayerRevived
PLAYER_SUICIDE PlayerSuicide
PLAYER_WOUNDED PlayerWounded
PLAYER_QUEUED PlayerQueued
ROUND_WINNER RoundWinner
ROUND_ENDED RoundEnded
ROUND_TICKETS RoundTickets
SQUAD_CREATED SquadCreated
VEHICLE_DAMAGED VehicleDamaged
SERVER_TICKRATE ServerTickrate

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFTPReader

func NewFTPReader(config FTPReaderConfig) (*fptReader, error)

func NewLocalReader

func NewLocalReader(config LocalReaderConfig) (*localReader, error)

Types

type FTPReaderConfig

type FTPReaderConfig struct {
	Host               string
	Username           string
	Password           string
	LogPath            string
	AdminsPath         string
	LogEnabled         bool
	AutoReconnect      bool
	AutoReconnectDelay int
}

type LocalReaderConfig

type LocalReaderConfig struct {
	LogPath            string
	AdminsPath         string
	AutoReconnect      bool
	AutoReconnectDelay int
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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