Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ v3 (feature): refactor logger middleware #1979

Merged
merged 7 commits into from
Sep 5, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
✨ v3 (feature): refactor logger middleware
- Make middleware extandable for 3rd-party loggers. (#1828)
  • Loading branch information
efectn committed Jul 18, 2022
commit 6b2b1d725b6a30e36bfbbc8a78150c7c7647cb3b
7 changes: 7 additions & 0 deletions middleware/logger/default_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/mattn/go-colorable"
"github.com/mattn/go-isatty"
"github.com/valyala/bytebufferpool"
"github.com/valyala/fasthttp"
"github.com/valyala/fasttemplate"
)

Expand Down Expand Up @@ -205,3 +206,9 @@ func beforeHandlerFunc(cfg Config) {
}
}
}

func appendInt(buf *bytebufferpool.ByteBuffer, v int) (int, error) {
old := len(buf.B)
buf.B = fasthttp.AppendUint(buf.B, v)
return len(buf.B) - old, nil
}
8 changes: 0 additions & 8 deletions middleware/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
"time"

"github.com/gofiber/fiber/v3"
"github.com/valyala/bytebufferpool"
"github.com/valyala/fasthttp"
)

// Logger variables
Expand Down Expand Up @@ -174,9 +172,3 @@ func New(config ...Config) fiber.Handler {
return nil
}
}

func appendInt(buf *bytebufferpool.ByteBuffer, v int) (int, error) {
old := len(buf.B)
buf.B = fasthttp.AppendUint(buf.B, v)
return len(buf.B) - old, nil
}