Commit 1f7fbc601bed676b04edf817497fa8947249f144
1 parent
3e936a3c2f
Exists in
master
logging user ID
Showing
1 changed file
with
4 additions
and
4 deletions
Show diff stats
main.go
... | ... | @@ -81,20 +81,20 @@ func (l *Logger) Log(format string, v ...interface{}) { |
81 | 81 | l.outputFile.WriteString(s) |
82 | 82 | } |
83 | 83 | |
84 | -func (l *Logger) RequestLog(req *http.Request, userid string) string { | |
84 | +func (l *Logger) RequestLog(req *http.Request, userID string) string { | |
85 | 85 | if l.outputFile == nil { |
86 | 86 | return "" |
87 | 87 | } |
88 | 88 | |
89 | - if userid == "" { | |
90 | - userid = "-" | |
89 | + if userID == "" { | |
90 | + userID = "-" | |
91 | 91 | } |
92 | 92 | |
93 | 93 | var b strings.Builder |
94 | 94 | b.WriteString("Request:\n") |
95 | 95 | // CLF-like header |
96 | 96 | ts := time.Now().Format(time.RFC3339) |
97 | - fmt.Fprintf(&b, "%s %s\n", req.RemoteAddr, ts) | |
97 | + fmt.Fprintf(&b, "%s %s %s\n", req.RemoteAddr, userID, ts) | |
98 | 98 | |
99 | 99 | headers := req.Header |
100 | 100 | content := headers.Get("Content-Type") | ... | ... |