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

optimize: latency use lowest time unit in logger middleware #2261

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions middleware/logger/logger_test.go
Expand Up @@ -13,12 +13,11 @@ import (
"testing"
"time"

"github.com/valyala/bytebufferpool"
"github.com/valyala/fasthttp"

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

// go test -run Test_Logger
Expand Down
3 changes: 1 addition & 2 deletions middleware/logger/tags.go
Expand Up @@ -3,7 +3,6 @@ package logger
import (
"fmt"
"strings"
"time"

"github.com/gofiber/fiber/v2"
)
Expand Down Expand Up @@ -192,7 +191,7 @@ func createTagMap(cfg *Config) map[string]LogFunc {
return output.WriteString(data.Pid)
},
TagLatency: func(output Buffer, c *fiber.Ctx, data *Data, extraParam string) (int, error) {
latency := data.Stop.Sub(data.Start).Round(time.Millisecond)
latency := data.Stop.Sub(data.Start)
return output.WriteString(fmt.Sprintf("%7v", latency))
},
TagTime: func(output Buffer, c *fiber.Ctx, data *Data, extraParam string) (int, error) {
Expand Down