diff --git a/example/client/client b/example/client/client index 19c352b..a58e6ac 100644 Binary files a/example/client/client and b/example/client/client differ diff --git a/logger.go b/logger.go index 39ff047..fa85cf5 100644 --- a/logger.go +++ b/logger.go @@ -32,12 +32,14 @@ func Logger(log *logrus.Logger, fields logrus.Fields) HandlerFunc { c.Next() // Logs it. entry := logrus.NewEntry(log).WithFields(m.fields(c.ResponseWriter, fields)) - if e := c.Err(); e == nil { + err := c.Err() + switch { + case err == nil: entry.Info(m.String()) - } else if e.Recovered() { - entry.Errorf("%s %s", m, e) - } else { - entry.Warnf("%s %s", m, e) + case err.Recovered(): + entry.Errorf("%s %s", m, err) + default: + entry.Warnf("%s %s", m, err) } } } diff --git a/logger_test.go b/logger_test.go index afc82b4..d5c2add 100644 --- a/logger_test.go +++ b/logger_test.go @@ -117,5 +117,5 @@ func sleep(_ *tcp.Context) { } func stumble(c *tcp.Context) { - c.Error(errors.New("my bad, sorry!")) + c.Error(errors.New("my bad, sorry")) } diff --git a/response.go b/response.go index 8581507..dd64468 100644 --- a/response.go +++ b/response.go @@ -58,7 +58,7 @@ func (r *responseWriter) incr(n int) { r.size += n } -func (r *responseWriter) rebase(w ResponseWriter) { +func (r *responseWriter) rebase(w io.WriteCloser) { r.ResponseWriter = w r.size = noWritten }