mirror of
https://github.com/astaxie/beego.git
synced 2024-11-21 22:20:55 +00:00
Fix file path logging for enableFullFilePath
This commit is contained in:
parent
ac3a549187
commit
77ddc3338f
@ -39,7 +39,6 @@ import (
|
||||
"os"
|
||||
"path"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@ -279,14 +278,25 @@ func (bl *BeeLogger) writeMsg(lm *LogMsg, v ...interface{}) error {
|
||||
|
||||
lm.Msg = bl.prefix + " " + lm.Msg
|
||||
|
||||
var (
|
||||
file string
|
||||
line int
|
||||
ok bool
|
||||
)
|
||||
|
||||
if bl.enableFuncCallDepth {
|
||||
_, file, line, ok := runtime.Caller(bl.loggerFuncCallDepth)
|
||||
_, file, line, ok = runtime.Caller(bl.loggerFuncCallDepth)
|
||||
if !ok {
|
||||
file = "???"
|
||||
line = 0
|
||||
}
|
||||
_, filename := path.Split(file)
|
||||
lm.Msg = "[" + filename + ":" + strconv.Itoa(line) + "] " + lm.Msg
|
||||
|
||||
if !bl.enableFullFilePath {
|
||||
_, file = path.Split(file)
|
||||
}
|
||||
lm.FilePath = file
|
||||
lm.LineNumber = line
|
||||
lm.Msg = fmt.Sprintf("[%s:%d] %s", lm.FilePath, lm.LineNumber, lm.Msg)
|
||||
}
|
||||
|
||||
//set level info in front of filename info
|
||||
|
Loading…
Reference in New Issue
Block a user