You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by st...@apache.org on 2022/03/16 10:12:25 UTC
[apisix-dashboard] branch master updated: fix: caller location error in logs (#2367)
This is an automated email from the ASF dual-hosted git repository.
starsz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-dashboard.git
The following commit(s) were added to refs/heads/master by this push:
new bc13bb9 fix: caller location error in logs (#2367)
bc13bb9 is described below
commit bc13bb9e844b85e48e41141fefc0f2abc7ca76b0
Author: LetsGO <97...@qq.com>
AuthorDate: Wed Mar 16 18:12:20 2022 +0800
fix: caller location error in logs (#2367)
---
api/internal/log/zap.go | 4 +++-
api/test/shell/cli_test.sh | 3 +++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/api/internal/log/zap.go b/api/internal/log/zap.go
index 1f3f44a..446dde7 100644
--- a/api/internal/log/zap.go
+++ b/api/internal/log/zap.go
@@ -43,16 +43,18 @@ func InitLogger() {
func GetLogger(logType Type) *zap.SugaredLogger {
_ = zap.RegisterSink("winfile", newWinFileSink)
+ skip := 2
writeSyncer := fileWriter(logType)
encoder := getEncoder(logType)
logLevel := getLogLevel()
if logType == AccessLog {
logLevel = zapcore.InfoLevel
+ skip = 0
}
core := zapcore.NewCore(encoder, writeSyncer, logLevel)
- zapLogger := zap.New(core, zap.AddCaller(), zap.AddCallerSkip(2))
+ zapLogger := zap.New(core, zap.AddCaller(), zap.AddCallerSkip(skip))
return zapLogger.Sugar()
}
diff --git a/api/test/shell/cli_test.sh b/api/test/shell/cli_test.sh
index d41f270..56d783f 100755
--- a/api/test/shell/cli_test.sh
+++ b/api/test/shell/cli_test.sh
@@ -200,6 +200,9 @@ stop_dashboard() {
stop_dashboard 6
[ $(grep -c "/apisix/admin/user/login" "${ACCESS_LOG_FILE}") -ne '0' ]
+
+ # check logging middleware
+ [ $(grep -c "filter/logging.go" "${ACCESS_LOG_FILE}") -ne '0' ]
}
#8