Order log columns more sensibly and drop port from remote addresses.

This commit is contained in:
Solderpunk 2020-07-01 23:44:59 +02:00
parent e547818455
commit 2241302856
1 changed files with 5 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import (
"net" "net"
"os" "os"
"strconv" "strconv"
"strings"
"time" "time"
) )
@ -17,8 +18,11 @@ type LogEntry struct {
func writeLogEntry(fp *os.File, entry LogEntry) { func writeLogEntry(fp *os.File, entry LogEntry) {
var line string var line string
line = entry.Time.Format(time.RFC3339) line = entry.Time.Format(time.RFC3339)
// Trim port from remote address
addr := entry.RemoteAddr.String()
addr = addr[0:strings.LastIndex(addr, ":")]
line += "\t" + addr
line += "\t" + strconv.Itoa(entry.Status) line += "\t" + strconv.Itoa(entry.Status)
line += "\t" + entry.RemoteAddr.String()
line += "\t" + entry.RequestURL line += "\t" + entry.RequestURL
line += "\n" line += "\n"
fp.WriteString(line) fp.WriteString(line)