cmd/present: add request address to logged errors

Change-Id: I504d29d7196b8c61cff5e92bb4244a34c9c41fa8
Reviewed-on: https://go-review.googlesource.com/24331
Reviewed-by: Andrew Gerrand <adg@golang.org>
This commit is contained in:
kortschak 2016-06-22 19:04:47 +09:30 committed by Andrew Gerrand
parent a2a552218a
commit 8b3828f1c8
1 changed files with 6 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import (
"html/template" "html/template"
"io" "io"
"log" "log"
"net"
"net/http" "net/http"
"os" "os"
"path/filepath" "path/filepath"
@ -37,7 +38,11 @@ func dirHandler(w http.ResponseWriter, r *http.Request) {
return return
} }
if isDir, err := dirList(w, name); err != nil { if isDir, err := dirList(w, name); err != nil {
log.Println(err) addr, _, e := net.SplitHostPort(r.RemoteAddr)
if e != nil {
addr = r.RemoteAddr
}
log.Printf("request from %s: %s", addr, err)
http.Error(w, err.Error(), 500) http.Error(w, err.Error(), 500)
return return
} else if isDir { } else if isDir {