Can disable request logging

This commit is contained in:
LittleSheep 2023-11-30 22:35:40 +08:00
parent a64e7499bc
commit 9f9ccedbc7
2 changed files with 12 additions and 8 deletions

View File

@ -21,10 +21,12 @@ func InitAdministration() *fiber.App {
TrustedProxies: viper.GetStringSlice("security.administration_trusted_proxies"), TrustedProxies: viper.GetStringSlice("security.administration_trusted_proxies"),
}) })
app.Use(logger.New(logger.Config{ if viper.GetBool("performance.request_logging") {
Output: log.Logger, app.Use(logger.New(logger.Config{
Format: "[Administration] [${time}] ${status} - ${latency} ${method} ${path}\n", Output: log.Logger,
})) Format: "[Administration] [${time}] ${status} - ${latency} ${method} ${path}\n",
}))
}
app.Use(basicauth.New(basicauth.Config{ app.Use(basicauth.New(basicauth.Config{
Realm: fmt.Sprintf("RoadSign v%s", roadsign.AppVersion), Realm: fmt.Sprintf("RoadSign v%s", roadsign.AppVersion),

View File

@ -22,10 +22,12 @@ func InitServer() *fiber.App {
BodyLimit: viper.GetInt("hypertext.limitation.max_body_size"), BodyLimit: viper.GetInt("hypertext.limitation.max_body_size"),
}) })
app.Use(logger.New(logger.Config{ if viper.GetBool("performance.request_logging") {
Output: log.Logger, app.Use(logger.New(logger.Config{
Format: "[Proxies] [${time}] ${status} - ${latency} ${method} ${path}\n", Output: log.Logger,
})) Format: "[Proxies] [${time}] ${status} - ${latency} ${method} ${path}\n",
}))
}
if viper.GetInt("hypertext.limitation.max_qps") > 0 { if viper.GetInt("hypertext.limitation.max_qps") > 0 {
app.Use(limiter.New(limiter.Config{ app.Use(limiter.New(limiter.Config{