feat: Add better log displaying
All checks were successful
Build Docker / BuildSite (push) Successful in 1m2s

This commit is contained in:
Nathan Woodburn 2024-06-22 17:51:52 +10:00
parent 8942a3a285
commit 52e1a761fb
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
2 changed files with 21 additions and 0 deletions

13
main.go
View File

@ -77,6 +77,19 @@ func getHandler(relPath string, w http.ResponseWriter, r *http.Request) {
logData, err := os.ReadFile(logFilePath) logData, err := os.ReadFile(logFilePath)
if err != nil { if err != nil {
logData = []byte("No log file found") logData = []byte("No log file found")
} else {
// Keep any lines that don't contain test and invert line order
lines := bytes.Split(logData, []byte("\n"))
var newLines [][]byte
for i := len(lines) - 1; i >= 0; i-- {
if !bytes.Contains(lines[i], []byte("Test")) {
newLines = append(newLines, lines[i])
}
}
// Add latest test line (excluding the last line which is empty)
newLines = append(newLines, lines[len(lines)-2])
logData = bytes.Join(newLines, []byte("\n"))
} }
// Create a map to hold the data // Create a map to hold the data

View File

@ -17,3 +17,11 @@ Sat 22 Jun 2024 17:33:25 AEST - Test
Sat 22 Jun 2024 17:33:37 AEST - Test Sat 22 Jun 2024 17:33:37 AEST - Test
Sat 22 Jun 2024 17:33:51 AEST - Test Sat 22 Jun 2024 17:33:51 AEST - Test
Sat 22 Jun 2024 17:36:21 AEST - Test Sat 22 Jun 2024 17:36:21 AEST - Test
Sat 22 Jun 2024 17:49:37 AEST - Test
Sat 22 Jun 2024 17:49:54 AEST - Test
Sat 22 Jun 2024 17:50:17 AEST - Test
Sat 22 Jun 2024 17:50:36 AEST - Test
Sat 22 Jun 2024 17:50:49 AEST - Test
Sat 22 Jun 2024 17:51:04 AEST - Test
Sat 22 Jun 2024 17:51:16 AEST - Test
Sat 22 Jun 2024 17:51:45 AEST - Test