Skip to content

Commit

Permalink
log user agent
Browse files Browse the repository at this point in the history
mainly so we know when bots are hitting the server
  • Loading branch information
odrling committed Sep 5, 2024
1 parent 96f806d commit 906447c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion server/producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ package server

import (
"net/http"
"os"
"time"

"github.com/danielgtaylor/huma/v2"
"github.com/danielgtaylor/huma/v2/adapters/humafiber"
Expand All @@ -26,7 +28,14 @@ func SetupProducer() (*fiber.App, huma.API) {
BodyLimit: 512 * 1024 * 1024,
})

app.Use(logger.New())
app.Use(logger.New(logger.Config{
Format: "${time} | ${status} | ${latency} | ${ip} | ${ua} | ${method} | ${path} | ${error}\n",
TimeFormat: "15:04:05",
TimeZone: "UTC",
TimeInterval: 500 * time.Millisecond,
Output: os.Stdout,
DisableColors: false,
}))

api := humafiber.New(app, huma.DefaultConfig("Producer", "1.0.0"))
routes(api)
Expand Down

0 comments on commit 906447c

Please sign in to comment.