@@ -11,8 +11,9 @@ import (
1111 "github.com/mroote/factorio-server-manager/bootstrap"
1212)
1313
14- func tailLog (filename string ) ([]string , error ) {
15- result := []string {}
14+ func TailLog (filename string ) ([]string , error ) {
15+ // Tail the Factorio game log file
16+ var result []string
1617
1718 config := bootstrap .GetConfig ()
1819
@@ -46,7 +47,7 @@ func getOffset(line string) (string, error) {
4647
4748func getStartTime (line string ) time.Time {
4849 re , _ := regexp .Compile (`\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}` )
49- date := string ( re .FindString (line ) )
50+ date := re .FindString (line )
5051 startTime , _ := time .Parse (time .RFC3339 , strings .Replace (date , " " , "T" , 1 )+ "Z" )
5152
5253 return startTime
@@ -67,10 +68,10 @@ func replaceTimestampInLine(line string, offset string, startTime time.Time) str
6768func reformatTimestamps (log []string ) []string {
6869 firstLine := log [0 ]
6970 startTime := getStartTime (firstLine )
70- result := []string {}
71+ var result []string
7172
72- for i := range log {
73- line : = strings .TrimLeft (log [ i ] , " \t " )
73+ for _ , line := range log {
74+ line = strings .TrimLeft (line , " \t " )
7475 offset , _ := getOffset (line )
7576 result = append (result , replaceTimestampInLine (line , offset , startTime ))
7677 }
0 commit comments