Skip to content

Commit

Permalink
Improve interface for custom logger func (#2225)
Browse files Browse the repository at this point in the history
* - logger: fix custom tag
- use real bytebufferpool dependency instead of the internal

* - logger: fix custom tag
- use real bytebufferpool dependency instead of the internal

* - logger: fix custom tag
- use real bytebufferpool dependency instead of the internal

* - logger: fix custom tag
- use real bytebufferpool dependency instead of the internal
  • Loading branch information
ReneWerner87 authored Nov 18, 2022
1 parent 92ce4aa commit e4b3b5c
Show file tree
Hide file tree
Showing 14 changed files with 114 additions and 390 deletions.
2 changes: 1 addition & 1 deletion ctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import (
"text/template"
"time"

"github.com/gofiber/fiber/v2/internal/bytebufferpool"
"github.com/gofiber/fiber/v2/internal/dictpool"
"github.com/gofiber/fiber/v2/internal/schema"
"github.com/gofiber/fiber/v2/utils"
"github.com/valyala/bytebufferpool"
"github.com/valyala/fasthttp"
)

Expand Down
2 changes: 1 addition & 1 deletion ctx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ import (
"text/template"
"time"

"github.com/gofiber/fiber/v2/internal/bytebufferpool"
"github.com/gofiber/fiber/v2/internal/storage/memory"
"github.com/gofiber/fiber/v2/utils"
"github.com/valyala/bytebufferpool"
"github.com/valyala/fasthttp"
)

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/mattn/go-colorable v0.1.13
github.com/mattn/go-isatty v0.0.16
github.com/mattn/go-runewidth v0.0.14
github.com/valyala/bytebufferpool v1.0.0
github.com/valyala/fasthttp v1.41.0
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab
)
Expand All @@ -14,6 +15,5 @@ require (
github.com/andybalholm/brotli v1.0.4 // indirect
github.com/klauspost/compress v1.15.9 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
)
2 changes: 1 addition & 1 deletion helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
"time"
"unsafe"

"github.com/gofiber/fiber/v2/internal/bytebufferpool"
"github.com/gofiber/fiber/v2/utils"
"github.com/valyala/bytebufferpool"
"github.com/valyala/fasthttp"
)

Expand Down
2 changes: 1 addition & 1 deletion hooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"testing"
"time"

"github.com/gofiber/fiber/v2/internal/bytebufferpool"
"github.com/gofiber/fiber/v2/utils"
"github.com/valyala/bytebufferpool"
)

var testSimpleHandler = func(c *Ctx) error {
Expand Down
22 changes: 0 additions & 22 deletions internal/bytebufferpool/LICENSE

This file was deleted.

111 changes: 0 additions & 111 deletions internal/bytebufferpool/bytebuffer.go

This file was deleted.

151 changes: 0 additions & 151 deletions internal/bytebufferpool/pool.go

This file was deleted.

2 changes: 1 addition & 1 deletion middleware/etag/etag.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"hash/crc32"

"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/internal/bytebufferpool"
"github.com/valyala/bytebufferpool"
)

var (
Expand Down
12 changes: 5 additions & 7 deletions middleware/logger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ app.Use(logger.New())

```go
app.Use(logger.New(logger.Config{
Format: "[${ip}]:${port} ${status} - ${method} ${path}\n",
Format: "[${ip}]:${port} ${status} - ${method} ${path}\n",
}))
```

Expand Down Expand Up @@ -80,8 +80,8 @@ app.Use(logger.New(logger.Config{
```go
app.Use(logger.New(logger.Config{
CustomTags: map[string]logger.LogFunc{
"custom_tag": func(buf *bytebufferpool.ByteBuffer, c *fiber.Ctx, data *Data, extraParam string) (int, error) {
return buf.WriteString("it is a custom tag")
"custom_tag": func(output logger.Buffer, c *fiber.Ctx, data *logger.Data, extraParam string) (int, error) {
return output.WriteString("it is a custom tag")
},
},
}))
Expand Down Expand Up @@ -145,11 +145,9 @@ type Config struct {
//
// Default: os.Stdout
Output io.Writer

enableColors bool
enableLatency bool
timeZoneLocation *time.Location
}

type LogFunc func(buf logger.Buffer, c *fiber.Ctx, data *logger.Data, extraParam string) (int, error)
```

## Default Config
Expand Down
Loading

0 comments on commit e4b3b5c

Please sign in to comment.