Browse Source

More useful input/output logging please for debugging

kegan/ignore-events-on-join
Kegan Dougal 8 years ago
parent
commit
8fe15076e9
  1. 6
      src/github.com/matrix-org/go-neb/server/server.go

6
src/github.com/matrix-org/go-neb/server/server.go

@ -37,10 +37,11 @@ func WithCORSOptions(handler http.HandlerFunc) http.HandlerFunc {
// MakeJSONAPI creates an HTTP handler which always responds to incoming requests with JSON responses. // MakeJSONAPI creates an HTTP handler which always responds to incoming requests with JSON responses.
func MakeJSONAPI(handler JSONRequestHandler) http.HandlerFunc { func MakeJSONAPI(handler JSONRequestHandler) http.HandlerFunc {
return func(w http.ResponseWriter, req *http.Request) { return func(w http.ResponseWriter, req *http.Request) {
log.WithFields(log.Fields{
logger := log.WithFields(log.Fields{
"method": req.Method, "method": req.Method,
"url": req.URL, "url": req.URL,
}).Print("Received request")
})
logger.Print(">>> Incoming request")
res, httpErr := handler.OnIncomingRequest(req) res, httpErr := handler.OnIncomingRequest(req)
// Set common headers returned regardless of the outcome of the request // Set common headers returned regardless of the outcome of the request
@ -62,6 +63,7 @@ func MakeJSONAPI(handler JSONRequestHandler) http.HandlerFunc {
jsonErrorResponse(w, req, &errors.HTTPError{nil, "Failed to serialise response as JSON", 500}) jsonErrorResponse(w, req, &errors.HTTPError{nil, "Failed to serialise response as JSON", 500})
return return
} }
logger.Print("<<< Returning response ", string(r))
resBytes = r resBytes = r
} }
w.Write(resBytes) w.Write(resBytes)

Loading…
Cancel
Save