proxy/httpproxy: fix v2 proxy log header

Replace all with capnslog
release-3.0
Gyu-Ho Lee 2016-05-23 15:36:11 -07:00
parent 663db2bbf8
commit dd8a36820e
3 changed files with 15 additions and 16 deletions

View File

@ -337,7 +337,7 @@ func (epc *etcdProcessCluster) Start() (err error) {
etcdp.donec = make(chan struct{}) etcdp.donec = make(chan struct{})
rs := readyStr rs := readyStr
if etcdp.cfg.isProxy { if etcdp.cfg.isProxy {
rs = "proxy: endpoints found" rs = "httpproxy: endpoints found"
} }
_, err := etcdp.proc.Expect(rs) _, err := etcdp.proc.Expect(rs)
readyC <- err readyC <- err

View File

@ -15,7 +15,6 @@
package httpproxy package httpproxy
import ( import (
"log"
"math/rand" "math/rand"
"net/url" "net/url"
"sync" "sync"
@ -135,10 +134,10 @@ func (ep *endpoint) Failed() {
ep.Available = false ep.Available = false
ep.Unlock() ep.Unlock()
log.Printf("proxy: marked endpoint %s unavailable", ep.URL.String()) plog.Printf("marked endpoint %s unavailable", ep.URL.String())
if ep.failFunc == nil { if ep.failFunc == nil {
log.Printf("proxy: no failFunc defined, endpoint %s will be unavailable forever.", ep.URL.String()) plog.Printf("no failFunc defined, endpoint %s will be unavailable forever.", ep.URL.String())
return return
} }
@ -149,7 +148,7 @@ func timedUnavailabilityFunc(wait time.Duration) func(*endpoint) {
return func(ep *endpoint) { return func(ep *endpoint) {
time.AfterFunc(wait, func() { time.AfterFunc(wait, func() {
ep.Available = true ep.Available = true
log.Printf("proxy: marked endpoint %s available, to retest connectivity", ep.URL.String()) plog.Printf("marked endpoint %s available, to retest connectivity", ep.URL.String())
}) })
} }
} }

View File

@ -19,7 +19,6 @@ import (
"fmt" "fmt"
"io" "io"
"io/ioutil" "io/ioutil"
"log"
"net" "net"
"net/http" "net/http"
"net/url" "net/url"
@ -76,8 +75,9 @@ func (p *reverseProxy) ServeHTTP(rw http.ResponseWriter, clientreq *http.Request
if clientreq.Body != nil { if clientreq.Body != nil {
proxybody, err = ioutil.ReadAll(clientreq.Body) proxybody, err = ioutil.ReadAll(clientreq.Body)
if err != nil { if err != nil {
msg := fmt.Sprintf("proxy: failed to read request body: %v", err) msg := fmt.Sprintf("failed to read request body: %v", err)
e := httptypes.NewHTTPError(http.StatusInternalServerError, msg) plog.Println(msg)
e := httptypes.NewHTTPError(http.StatusInternalServerError, "httpproxy: "+msg)
if we := e.WriteTo(rw); we != nil { if we := e.WriteTo(rw); we != nil {
plog.Debugf("error writing HTTPError (%v) to %s", we, clientreq.RemoteAddr) plog.Debugf("error writing HTTPError (%v) to %s", we, clientreq.RemoteAddr)
} }
@ -95,12 +95,12 @@ func (p *reverseProxy) ServeHTTP(rw http.ResponseWriter, clientreq *http.Request
endpoints := p.director.endpoints() endpoints := p.director.endpoints()
if len(endpoints) == 0 { if len(endpoints) == 0 {
msg := "proxy: zero endpoints currently available" msg := "zero endpoints currently available"
reportRequestDropped(clientreq, zeroEndpoints) reportRequestDropped(clientreq, zeroEndpoints)
// TODO: limit the rate of the error logging. // TODO: limit the rate of the error logging.
log.Printf(msg) plog.Println(msg)
e := httptypes.NewHTTPError(http.StatusServiceUnavailable, msg) e := httptypes.NewHTTPError(http.StatusServiceUnavailable, "httpproxy: "+msg)
if we := e.WriteTo(rw); we != nil { if we := e.WriteTo(rw); we != nil {
plog.Debugf("error writing HTTPError (%v) to %s", we, clientreq.RemoteAddr) plog.Debugf("error writing HTTPError (%v) to %s", we, clientreq.RemoteAddr)
} }
@ -117,7 +117,7 @@ func (p *reverseProxy) ServeHTTP(rw http.ResponseWriter, clientreq *http.Request
select { select {
case <-closeCh: case <-closeCh:
atomic.StoreInt32(&requestClosed, 1) atomic.StoreInt32(&requestClosed, 1)
log.Printf("proxy: client %v closed request prematurely", clientreq.RemoteAddr) plog.Printf("client %v closed request prematurely", clientreq.RemoteAddr)
cancel() cancel()
case <-completeCh: case <-completeCh:
} }
@ -142,7 +142,7 @@ func (p *reverseProxy) ServeHTTP(rw http.ResponseWriter, clientreq *http.Request
} }
if err != nil { if err != nil {
reportRequestDropped(clientreq, failedSendingRequest) reportRequestDropped(clientreq, failedSendingRequest)
log.Printf("proxy: failed to direct request to %s: %v", ep.URL.String(), err) plog.Printf("failed to direct request to %s: %v", ep.URL.String(), err)
ep.Failed() ep.Failed()
continue continue
} }
@ -152,10 +152,10 @@ func (p *reverseProxy) ServeHTTP(rw http.ResponseWriter, clientreq *http.Request
if res == nil { if res == nil {
// TODO: limit the rate of the error logging. // TODO: limit the rate of the error logging.
msg := fmt.Sprintf("proxy: unable to get response from %d endpoint(s)", len(endpoints)) msg := fmt.Sprintf("unable to get response from %d endpoint(s)", len(endpoints))
reportRequestDropped(clientreq, failedGettingResponse) reportRequestDropped(clientreq, failedGettingResponse)
log.Printf(msg) plog.Println(msg)
e := httptypes.NewHTTPError(http.StatusBadGateway, msg) e := httptypes.NewHTTPError(http.StatusBadGateway, "httpproxy: "+msg)
if we := e.WriteTo(rw); we != nil { if we := e.WriteTo(rw); we != nil {
plog.Debugf("error writing HTTPError (%v) to %s", we, clientreq.RemoteAddr) plog.Debugf("error writing HTTPError (%v) to %s", we, clientreq.RemoteAddr)
} }