1
0
mirror of https://github.com/labstack/echo.git synced 2024-12-22 20:06:21 +02:00

Logger test cases

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana 2016-03-06 09:10:42 -08:00
parent d6af11ec08
commit 56e678ff4d
3 changed files with 3 additions and 12 deletions

View File

@ -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)

View File

@ -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
}
}

View File

@ -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")