From 71149218d17b7f5843c9d5c17ce95be22739e26e Mon Sep 17 00:00:00 2001 From: astaxie Date: Thu, 30 Oct 2014 17:43:32 +0800 Subject: [PATCH] fix the log level --- config.go | 1 + logs/log.go | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/config.go b/config.go index 84f8cf39..8a819dad 100644 --- a/config.go +++ b/config.go @@ -277,6 +277,7 @@ func init() { if err != nil { fmt.Println("init console log error:", err) } + BeeLogger.SetLogFuncCallDepth(true) err = ParseConfig() if err != nil && !os.IsNotExist(err) { diff --git a/logs/log.go b/logs/log.go index 341df572..b61388e6 100644 --- a/logs/log.go +++ b/logs/log.go @@ -154,7 +154,10 @@ func (bl *BeeLogger) writerMsg(loglevel int, msg string) error { lm := new(logMsg) lm.level = loglevel if bl.enableFuncCallDepth { - _, file, line, ok := runtime.Caller(bl.loggerFuncCallDepth) + _, file, line, ok := runtime.Caller(bl.loggerFuncCallDepth + 1) + if !ok { + _, file, line, ok = runtime.Caller(bl.loggerFuncCallDepth) + } if ok { _, filename := path.Split(file) lm.msg = fmt.Sprintf("[%s:%d] %s", filename, line, msg)