Files
cluster/internal/middleware/logger.go
loveuer 29088a6b54 feat: complete OCI registry implementation with docker push/pull support
A lightweight OCI (Open Container Initiative) registry implementation written in Go.
2025-11-09 22:50:13 +08:00

32 lines
486 B
Go

package middleware
import (
"fmt"
"time"
"github.com/gofiber/fiber/v3"
)
// Logger 日志中间件
func Logger() fiber.Handler {
return func(c fiber.Ctx) error {
start := time.Now()
err := c.Next()
latency := time.Since(start)
fmt.Printf("%s - [%s] \"%s %s %s %d %s \"%s\" %s\"\n",
c.IP(),
time.Now().Format(time.RFC1123),
c.Method(),
c.Path(),
c.Protocol(),
c.Response().StatusCode(),
latency,
c.Get("User-Agent"),
"",
)
return err
}
}