Add request logging to panic recovery #63
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "issue-61"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
When a panic occurs in a request, this patch makes sure that some info about the request is logged.
Fixes #61
@ -32,1 +33,4 @@ts := time.Now()return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {logRequestInfo := func() {host, _, err := net.SplitHostPort(r.RemoteAddr)I don't see a reason why the source port needs to be chopped off. Besides, the
net/httpserver guarantees (by means of documentation) thathttp.Request.RemoteAddris filled usingIP:port, so this check should not be necessary.@ -33,0 +37,4 @@if err != nil {host = r.RemoteAddr}timeDesc := ts.Format("02/Jan/2006:15:04:05 -0700")log.Printfalready registers the timestamp. What's the use of a second timestamp here?@ -33,0 +38,4 @@host = r.RemoteAddr}timeDesc := ts.Format("02/Jan/2006:15:04:05 -0700")log.Printf("in request: [%s] %v - %v '%s' %v", timeDesc, host, r.Method, r.RequestURI, r.Proto)Instead of
'%s', you may use%q, which automatically quotes the supplied string.