Skip to content

Commit

Permalink
don't log requests
Browse files Browse the repository at this point in the history
  • Loading branch information
dustin-decker committed Sep 22, 2018
1 parent a210eea commit 48c3482
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 1 addition & 3 deletions recovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"io/ioutil"
"log"
"net/http"
"net/http/httputil"
"runtime"
"time"
)
Expand Down Expand Up @@ -39,8 +38,7 @@ func RecoveryWithWriter(out io.Writer) HandlerFunc {
if err := recover(); err != nil {
if logger != nil {
stack := stack(3)
httprequest, _ := httputil.DumpRequest(c.Request, false)
logger.Printf("[Recovery] %s panic recovered:\n%s\n%s\n%s%s", timeFormat(time.Now()), string(httprequest), err, stack, reset)
logger.Printf("[Recovery] %s panic recovered:\n%s\n%s%s", timeFormat(time.Now()), err, stack, reset)
}
c.AbortWithStatus(http.StatusInternalServerError)
}
Expand Down
2 changes: 1 addition & 1 deletion recovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestPanicInHandler(t *testing.T) {
w := performRequest(router, "GET", "/recovery")
// TEST
assert.Equal(t, http.StatusInternalServerError, w.Code)
assert.Contains(t, buffer.String(), "GET /recovery")
assert.Contains(t, buffer.String(), "panic recovered")
assert.Contains(t, buffer.String(), "Oupps, Houston, we have a problem")
assert.Contains(t, buffer.String(), "TestPanicInHandler")
}
Expand Down

0 comments on commit 48c3482

Please sign in to comment.