1
0
Fork 0
molly-brown/logging.go

26 lines
425 B
Go
Raw Normal View History

2019-11-06 11:38:41 -05:00
package main
import (
"net"
"os"
"strconv"
"time"
2019-11-06 11:38:41 -05:00
)
type LogEntry struct {
Time time.Time
RemoteAddr net.Addr
RequestURL string
Status int
2019-11-06 11:38:41 -05:00
}
func writeLogEntry(fp *os.File, entry LogEntry) {
var line string
2019-11-22 14:51:47 -05:00
line = entry.Time.Format(time.RFC3339)
2019-11-06 11:38:41 -05:00
line += "\t" + strconv.Itoa(entry.Status)
line += "\t" + entry.RemoteAddr.String()
line += "\t" + entry.RequestURL
line += "\n"
fp.WriteString(line)
}