The line number printed in log is not correct
Opened this issue · 6 comments
EriconYu commented
The line number printed in log is not correct,eg:
package main
import (
"fmt"
"github.com/cihub/seelog"
)
func init() {
seelogInit()
}
func seelogInit() {
// Log, err := seelog.LoggerFromConfigAsBytes([]byte(seelogConfig))
Log, err := seelog.LoggerFromConfigAsFile("seelog.xml")
if err != nil {
fmt.Println("seelog init failed!!!")
panic(err)
}
seelog.ReplaceLogger(Log)
seelog.Info("seelog init success!")
}
Console prints :
2017-07-06 16:04:47 [init.go:23] [INF] seelog init success!
but actual should be :
2017-07-06 16:04:47 [init.go:22] [INF] seelog init success!
EriconYu commented
xml content is :
<seelog type="sync">
<outputs formatid="main">
<filter levels="info,debug,critical,error">
<console />
</filter>
<filter levels="info,debug,critical,error">
<file path="log.txt" />
</filter>
</outputs>
<formats>
<format id="main" format="%Date %Time [%File:%Line] [%LEV] %Msg%n"/>
</formats>
</seelog>
go version is
go version go1.8 linux/amd64
antsbean commented
that's true
nelsonzhu commented
func extractCallerInfo(skip int) (*logContext, error) {
var shortPath string
pc, fullPath, line, ok := runtime.Caller(skip)
if !ok {
return nil, errors.New("error during runtime.Callers")
}
// do we have a cache entry?
stackCacheLock.RLock()
ctx, ok := stackCache[pc]
stackCacheLock.RUnlock()
if ok {
return ctx, nil
}
Kurt-Shiwz commented
line number still wrong
skydroplet commented
use tag v2.6, don't use the master, v2.6 is correct