remove dead log handler and increase verbosity
Kubernetes-commit: 9e263af7dacafe590cc585f0c37123310a2a9a4f
This commit is contained in:
parent
e057ae1d55
commit
0ee5e1006e
|
@ -10,7 +10,7 @@ load(
|
|||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["log_test.go"],
|
||||
srcs = ["httplog_test.go"],
|
||||
library = ":go_default_library",
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
|
@ -19,7 +19,7 @@ go_library(
|
|||
name = "go_default_library",
|
||||
srcs = [
|
||||
"doc.go",
|
||||
"log.go",
|
||||
"httplog.go",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
deps = ["//vendor/github.com/golang/glog:go_default_library"],
|
||||
|
|
|
@ -27,18 +27,6 @@ import (
|
|||
"github.com/golang/glog"
|
||||
)
|
||||
|
||||
// Handler wraps all HTTP calls to delegate with nice logging.
|
||||
// delegate may use LogOf(w).Addf(...) to write additional info to
|
||||
// the per-request log message.
|
||||
//
|
||||
// Intended to wrap calls to your ServeMux.
|
||||
func Handler(delegate http.Handler, pred StacktracePred) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||
defer NewLogged(req, &w).StacktraceWhen(pred).Log()
|
||||
delegate.ServeHTTP(w, req)
|
||||
})
|
||||
}
|
||||
|
||||
// StacktracePred returns true if a stacktrace should be logged for this status.
|
||||
type StacktracePred func(httpStatus int) (logStacktrace bool)
|
||||
|
|
@ -17,7 +17,6 @@ limitations under the License.
|
|||
package httplog
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"reflect"
|
||||
|
@ -38,28 +37,6 @@ func TestDefaultStacktracePred(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestHandler(t *testing.T) {
|
||||
want := &httptest.ResponseRecorder{
|
||||
HeaderMap: make(http.Header),
|
||||
Body: new(bytes.Buffer),
|
||||
}
|
||||
want.WriteHeader(http.StatusOK)
|
||||
mux := http.NewServeMux()
|
||||
handler := Handler(mux, DefaultStacktracePred)
|
||||
mux.HandleFunc("/kube", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
})
|
||||
req, err := http.NewRequest("GET", "http://example.com/kube", nil)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error: %v", err)
|
||||
}
|
||||
w := httptest.NewRecorder()
|
||||
handler.ServeHTTP(w, req)
|
||||
if !reflect.DeepEqual(want, w) {
|
||||
t.Errorf("Expected %v, got %v", want, w)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStatusIsNot(t *testing.T) {
|
||||
statusTestTable := []struct {
|
||||
status int
|
Loading…
Reference in New Issue