From 40e341db5114365214cf8354587f4e5fae4f2b2a Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Wed, 5 Apr 2017 22:35:33 -0700 Subject: [PATCH] cmd/helloserver: don't log healthchecks --- cmd/helloserver/main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/helloserver/main.go b/cmd/helloserver/main.go index fb81a86..feae031 100644 --- a/cmd/helloserver/main.go +++ b/cmd/helloserver/main.go @@ -30,5 +30,9 @@ func handle(w http.ResponseWriter, r *http.Request) { hn, _ := os.Hostname() fmt.Fprintf(w, "Served by %s running %s\n", hn, runtime.GOOS) fmt.Fprintf(w, "Hit count: %d", hits.Inc()) - log.Printf("Hit from %s: %s", r.Header.Get("X-Remote-Ip"), r.RequestURI) + + ip := r.Header.Get("X-Remote-Ip") + if ip != "" { + log.Printf("Hit from %s: %s", ip, r.RequestURI) + } }