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