fix(#48): silence the empty per-request access log line

Every API request logged one bare "info" line with no message: upstream
calls log.WithFields(logData).Info(), and the console formatter does not
render fields, so status, latency, IP, method and URI all went nowhere.
One line of pure noise per request.

Give the line its message and demote it to debug. The payload is worth
having when diagnosing a slow or failing request, so it is recoverable
by setting logger.level back to debug rather than deleted.

settings.yml drops from trace to info accordingly. Nothing else in the
project logs below info: the many .Debug() calls are gorm SQL echo, which
is unaffected by logger level.

This patches upstream go-admin middleware, marked as such in a comment.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
QiuSW
2026-08-20 09:47:45 +08:00
co-authored by Claude Opus 5
parent 72ecf25291
commit d7a15e9525
2 changed files with 9 additions and 2 deletions
+6 -1
View File
@@ -90,7 +90,12 @@ func LoggerToFile() gin.HandlerFunc {
"method": reqMethod,
"uri": reqUri,
}
log.WithFields(logData).Info()
// GoAuto 改动(#48):上游这里是 log.WithFields(logData).Info(),不带任何
// 消息。控制台格式化器不渲染 fields,于是每个请求打出一行**空的** info——
// 一行零信息量的噪音。这里补上消息体,并降到 debug 级:
// settings.yml 的 logger.level 设为 debug 或 trace 时才输出。
log.WithFields(logData).Debugf("%s %s %d %s %s",
reqMethod, reqUri, statusCode, latencyTime, clientIP)
defer func() {
log.Fields(map[string]interface{}{})
}()
+3 -1
View File
@@ -18,7 +18,9 @@ settings:
# 日志输出,file:文件,default:命令行,其他:命令行
stdout: '' #控制台日志,启用后,不输出到文件
# 日志等级, trace, debug, info, warn, error, fatal
level: trace
# trace 会打出每个请求的访问日志(common/middleware/logger.go)。
# 默认 info:正常运行只保留启动信息、警告和错误;排查请求问题时改回 debug。
level: info
# 数据库日志开关
enableddb: false
jwt: