From 624717e801464e2079d1b8621db7cc69f85d59e1 Mon Sep 17 00:00:00 2001 From: Ali Reza Date: Wed, 25 May 2016 18:13:22 +0700 Subject: [PATCH 1/2] Log HTTP server errors using common/log change naming to be more descriptive. Fixes #1651 remove pointer receiver use common/log error logger --- web/web.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web/web.go b/web/web.go index 4c345d63e..d321fc041 100644 --- a/web/web.go +++ b/web/web.go @@ -239,7 +239,12 @@ func (h *Handler) Reload() <-chan struct{} { // Run serves the HTTP endpoints. func (h *Handler) Run() { log.Infof("Listening on %s", h.options.ListenAddress) - h.listenErrCh <- http.ListenAndServe(h.options.ListenAddress, h.router) + server := &http.Server{ + Addr: h.options.ListenAddress, + Handler: h.router, + ErrorLog: log.NewErrorLogger(), + } + h.listenErrCh <- server.ListenAndServe() } func (h *Handler) alerts(w http.ResponseWriter, r *http.Request) { From 5e2b197a000effeac6ee01954288834bbee17d33 Mon Sep 17 00:00:00 2001 From: Ali Reza Date: Thu, 26 May 2016 23:19:09 +0700 Subject: [PATCH 2/2] Update vendoring for github.com/prometheus/common/log --- vendor/github.com/prometheus/common/log/log.go | 14 ++++++++++++++ vendor/vendor.json | 6 +++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/vendor/github.com/prometheus/common/log/log.go b/vendor/github.com/prometheus/common/log/log.go index 07fbfef61..fb9ec44ec 100644 --- a/vendor/github.com/prometheus/common/log/log.go +++ b/vendor/github.com/prometheus/common/log/log.go @@ -16,6 +16,7 @@ package log import ( "flag" "fmt" + "log" "net/url" "os" "runtime" @@ -302,3 +303,16 @@ func Fatalln(args ...interface{}) { func Fatalf(format string, args ...interface{}) { baseLogger.sourced().Fatalf(format, args...) } + +type errorLogWriter struct{} + +func (errorLogWriter) Write(b []byte) (int, error) { + baseLogger.sourced().Error(string(b)) + return len(b), nil +} + +// NewErrorLogger returns a log.Logger that is meant to be used +// in the ErrorLog field of an http.Server to log HTTP server errors. +func NewErrorLogger() *log.Logger { + return log.New(&errorLogWriter{}, "", 0) +} diff --git a/vendor/vendor.json b/vendor/vendor.json index 94a84800f..2cefe093a 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -173,10 +173,10 @@ "revisionTime": "2016-05-19T16:20:33Z" }, { - "checksumSHA1": "koBNYQryxAG8hyHBlpn8pcnSVdM=", + "checksumSHA1": "qHoBp/PVBcLedTNZrF3toV9QGa0=", "path": "github.com/prometheus/common/log", - "revision": "c16e34897a744c32f6733ee720e60c4de13887fb", - "revisionTime": "2016-05-19T16:20:33Z" + "revision": "a6ab08426bb262e2d190097751f5cfd1cfdfd17d", + "revisionTime": "2016-05-26T15:55:09Z" }, { "checksumSHA1": "Zgmg/aOfoCNTAMtrXqBJmt852t0=",