diff --git a/formatters/json_formatter.go b/formatters/json_formatter.go index 9f362db..f669b33 100644 --- a/formatters/json_formatter.go +++ b/formatters/json_formatter.go @@ -9,7 +9,7 @@ import ( "sync" "time" - "github.com/subchen/go-log" + "github.com/fangdingjun/go-log" ) // JSONFormatter is a json formatter @@ -41,7 +41,7 @@ func (f *JSONFormatter) Format(level log.Level, msg string, logger *log.Logger) data := make(map[string]interface{}, 8) // file, line - file, line := FilelineCaller(5) + file, line := FilelineCaller(4) data["time"] = time.Now().Format(f.TimeFormat) data["level"] = level.String() diff --git a/formatters/text_formatter.go b/formatters/text_formatter.go index 33b0cb7..7fe3bc6 100644 --- a/formatters/text_formatter.go +++ b/formatters/text_formatter.go @@ -8,7 +8,7 @@ import ( "sync" "time" - "github.com/subchen/go-log" + "github.com/fangdingjun/go-log" ) var ( @@ -83,7 +83,7 @@ func (f *TextFormatter) Format(level log.Level, msg string, logger *log.Logger) buf.Write(f.pid) // file, line - file, line := FilelineCaller(5) + file, line := FilelineCaller(4) buf.WriteByte(' ') buf.WriteString(file) buf.WriteByte(':') diff --git a/formatters/util_fileline.go b/formatters/util_fileline.go index 3f2b3c3..4b4047d 100644 --- a/formatters/util_fileline.go +++ b/formatters/util_fileline.go @@ -13,6 +13,11 @@ func FilelineCaller(skip int) (file string, line int) { return "???", 0 } + //fmt.Printf("%s:%d\n", file, line) + if strings.Contains(file, "go-log/") { + continue + } + // file = pkg/file.go n := 0 for i := len(file) - 1; i > 0; i-- { @@ -24,10 +29,7 @@ func FilelineCaller(skip int) (file string, line int) { } } } - - if !strings.HasPrefix(file, "go-log/") { - return file, line - } + return file, line } return "???", 0