Skip to content

Commit

Permalink
feat: add user-agent log
Browse files Browse the repository at this point in the history
  • Loading branch information
JingYiJun committed Oct 16, 2023
1 parent ba74c83 commit 80343bb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions internal/server/middlewares.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import (
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
fiberrecover "github.com/gofiber/fiber/v2/middleware/recover"
"github.com/rs/zerolog/log"

"github.com/opentreehole/backend/internal/config"
"github.com/opentreehole/backend/internal/schema"
"github.com/opentreehole/backend/pkg/utils"
"github.com/rs/zerolog/log"
)

func GetUserID(c *fiber.Ctx) (int, error) {
Expand Down Expand Up @@ -77,7 +78,8 @@ func MiddlewareCustomLogger(c *fiber.Ctx) error {
Str("method", c.Method()).
Str("origin_url", c.OriginalURL()).
Str("remote_ip", c.Get("X-Real-IP")).
Int64("latency", latency)
Int64("latency", latency).
Str("user_agent", c.Get("User-Agent"))
if ok {
output = output.Int("user_id", userID)
}
Expand Down

0 comments on commit 80343bb

Please sign in to comment.