better logging

This commit is contained in:
Daniel Smith 2014-12-19 12:28:51 -08:00
parent 5807b3d6bc
commit be9f3be709
2 changed files with 5 additions and 5 deletions

View File

@ -62,7 +62,7 @@ type UnexpectedStatusError struct {
// Error returns a textual description of 'u'.
func (u *UnexpectedStatusError) Error() string {
return fmt.Sprintf("request [%#v] failed (%d) %s: %s", u.Request, u.Response.StatusCode, u.Response.Status, u.Body)
return fmt.Sprintf("request [%+v] failed (%d) %s: %s", u.Request, u.Response.StatusCode, u.Response.Status, u.Body)
}
// RequestConstructionError is returned when there's an error assembling a request.
@ -242,7 +242,7 @@ func (r *Request) Body(obj interface{}) *Request {
}
r.body = bytes.NewBuffer(data)
default:
r.err = fmt.Errorf("unknown type used for body: %#v", obj)
r.err = fmt.Errorf("unknown type used for body: %+v", obj)
}
return r
}
@ -309,7 +309,7 @@ func (r *Request) Watch() (watch.Interface, error) {
if resp.Body != nil {
body, _ = ioutil.ReadAll(resp.Body)
}
return nil, fmt.Errorf("for request '%v', got status: %v\nbody: %v", req.URL, resp.StatusCode, string(body))
return nil, fmt.Errorf("for request '%+v', got status: %v\nbody: %v", req.URL, resp.StatusCode, string(body))
}
return watch.NewStreamWatcher(watchjson.NewDecoder(resp.Body, r.codec)), nil
}

View File

@ -168,8 +168,8 @@ func (rl *respLogger) Write(b []byte) (int, error) {
func (rl *respLogger) Flush() {
if flusher, ok := rl.w.(http.Flusher); ok {
flusher.Flush()
} else {
glog.V(2).Infof("Unable to convert %v into http.Flusher", rl.w)
} else if glog.V(2) {
glog.InfoDepth(1, fmt.Sprintf("Unable to convert %+v into http.Flusher", rl.w))
}
}