Order log columns more sensibly and drop port from remote addresses.
This commit is contained in:
parent
e547818455
commit
2241302856
|
@ -4,6 +4,7 @@ import (
|
|||
"net"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -17,8 +18,11 @@ type LogEntry struct {
|
|||
func writeLogEntry(fp *os.File, entry LogEntry) {
|
||||
var line string
|
||||
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" + entry.RemoteAddr.String()
|
||||
line += "\t" + entry.RequestURL
|
||||
line += "\n"
|
||||
fp.WriteString(line)
|
||||
|
|
Loading…
Reference in New Issue