From 493ea92280f9168927de83b6e722ce6a2a0f3789 Mon Sep 17 00:00:00 2001 From: wei cheng Date: Sun, 12 May 2019 20:27:12 +0800 Subject: [PATCH] fix log incorrect source when use pattern render --- pkg/log/pattern.go | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/pkg/log/pattern.go b/pkg/log/pattern.go index 89609d6b6..13c6450f2 100644 --- a/pkg/log/pattern.go +++ b/pkg/log/pattern.go @@ -4,8 +4,6 @@ import ( "bytes" "fmt" "io" - "path" - "runtime" "strings" "sync" "time" @@ -27,8 +25,8 @@ var patternMap = map[string]func(map[string]interface{}) string{ "i": keyFactory(_instanceID), "e": keyFactory(_deplyEnv), "z": keyFactory(_zone), - "S": longSource, - "s": shortSource, + "S": keyFactory(_source), + "s": keyFactory(_source), "M": message, } @@ -116,20 +114,6 @@ func keyFactory(key string) func(map[string]interface{}) string { } } -func longSource(map[string]interface{}) string { - if _, file, lineNo, ok := runtime.Caller(6); ok { - return fmt.Sprintf("%s:%d", file, lineNo) - } - return "unknown:0" -} - -func shortSource(map[string]interface{}) string { - if _, file, lineNo, ok := runtime.Caller(6); ok { - return fmt.Sprintf("%s:%d", path.Base(file), lineNo) - } - return "unknown:0" -} - func longTime(map[string]interface{}) string { return time.Now().Format("15:04:05.000") }