dump 로직, 로깅 로직 개선
This commit is contained in:
@@ -129,12 +129,22 @@ func newFileLogger(path string) fiber.Handler {
|
||||
return func(c *fiber.Ctx) error { return c.Next() }
|
||||
}
|
||||
|
||||
format := "${time} ${ip} ${method} ${path} ${protocol} ${status} ${latency_human} headers=${reqHeaders}\n"
|
||||
format := "${time} ip=${ip} real_ip=${header:X-Real-IP} forwarded=${header:X-Forwarded-For} ${method} ${path} ${protocol} ${status} ${latency_human} ua=\"${ua}\" headers=\"${reqHeadersShort}\"\n"
|
||||
cfg := logger.Config{
|
||||
Format: format,
|
||||
TimeFormat: time.RFC3339,
|
||||
TimeZone: "Asia/Seoul",
|
||||
Output: writer,
|
||||
CustomTags: map[string]logger.LogFunc{
|
||||
"reqHeadersShort": func(output logger.Buffer, c *fiber.Ctx, data *logger.Data, param string) (int, error) {
|
||||
const max = 1024
|
||||
h := c.Request().Header.String()
|
||||
if len(h) > max {
|
||||
h = h[:max] + "...(truncated)"
|
||||
}
|
||||
return output.WriteString(strings.TrimSpace(h))
|
||||
},
|
||||
},
|
||||
}
|
||||
return logger.New(cfg)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user