add access log

pull/5/head
kun 2018-09-05 13:46:10 +08:00
parent 9a38b201ef
commit aafa0fc010
1 changed files with 2 additions and 2 deletions

View File

@ -37,7 +37,7 @@ func main() {
func mainHandler(inner http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(os.Stdout, "goproxy: download %s\n", r.URL.Path)
fmt.Fprintf(os.Stdout, "goproxy: %s download %s\n", r.RemoteAddr, r.URL.Path)
if _, err := os.Stat(filepath.Join(cacheDir, r.URL.Path)); err != nil {
if strings.HasSuffix(r.URL.Path, ".info") || strings.HasSuffix(r.URL.Path, ".mod") {
suffix := ".mod"
@ -101,7 +101,7 @@ func goGet(path, version, suffix string, w http.ResponseWriter, r *http.Request)
}
if err := cmd.Wait(); err != nil {
fmt.Fprintf(os.Stderr, "goproxy: download %s stderr:\n %s", path, string(bytesErr))
fmt.Fprintf(os.Stderr, "goproxy: download %s stderr:\n%s", path, string(bytesErr))
return err
}
out := fmt.Sprintf("%s", bytesErr)