From 56e678ff4dec78fdd27dc2dc57cc4ce5d016e86f Mon Sep 17 00:00:00 2001 From: Vishal Rana Date: Sun, 6 Mar 2016 09:10:42 -0800 Subject: [PATCH] Logger test cases Signed-off-by: Vishal Rana --- echo_test.go | 6 ------ middleware/logger.go | 2 +- middleware/logger_test.go | 7 ++----- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/echo_test.go b/echo_test.go index 72e37ceb..ceb9b0c7 100644 --- a/echo_test.go +++ b/echo_test.go @@ -12,7 +12,6 @@ import ( "errors" - "github.com/labstack/gommon/log" "github.com/stretchr/testify/assert" "golang.org/x/net/websocket" ) @@ -41,11 +40,6 @@ func TestEcho(t *testing.T) { e.DefaultHTTPErrorHandler(errors.New("error"), c) assert.Equal(t, http.StatusInternalServerError, rec.Code) - // Logger - l := log.New("test") - e.SetLogger(l) - assert.Equal(t, l, e.Logger()) - // Autoindex e.AutoIndex(true) assert.True(t, e.autoIndex) diff --git a/middleware/logger.go b/middleware/logger.go index 8aa6f52c..a28b9e2c 100644 --- a/middleware/logger.go +++ b/middleware/logger.go @@ -52,7 +52,7 @@ func Logger() echo.MiddlewareFunc { code = color.Cyan(n) } - logger.Infof(format, remoteAddr, method, path, code, stop.Sub(start), size) + logger.Printf(format, remoteAddr, method, path, code, stop.Sub(start), size) return nil } } diff --git a/middleware/logger_test.go b/middleware/logger_test.go index 3ae4970b..298154b4 100644 --- a/middleware/logger_test.go +++ b/middleware/logger_test.go @@ -8,7 +8,6 @@ import ( "testing" "github.com/labstack/echo" - "github.com/labstack/gommon/log" "github.com/stretchr/testify/assert" ) @@ -53,13 +52,11 @@ func TestLogger(t *testing.T) { func TestLoggerIPAddress(t *testing.T) { e := echo.New() - l := log.New("echo") - buf := new(bytes.Buffer) - l.SetOutput(buf) - e.SetLogger(l) req, _ := http.NewRequest(echo.GET, "/", nil) rec := httptest.NewRecorder() c := echo.NewContext(req, echo.NewResponse(rec, e), e) + buf := new(bytes.Buffer) + e.Logger().SetOutput(buf) ip := "127.0.0.1" h := func(c *echo.Context) error { return c.String(http.StatusOK, "test")