inconshreveable / log15

Structured, composable logging for Go
https://godoc.org/github.com/inconshreveable/log15
Other
1.1k stars 145 forks source link

Expose the runtime.Callers skip #134

Closed notzippy closed 7 years ago

notzippy commented 7 years ago

I was embedding your logger and now have the issue were the logged line is incorrect - I could write my handler to replace the set record.CallPC but that is a second call to runtime.Callers - it would be simpler if this was changed like

func (l *logger) write(msg string, lvl Lvl, ctx []interface{}) {
    r := Record{
        Time: time.Now(),
        Lvl:  lvl,
        Msg:  msg,
        Ctx:  newContext(l.ctx, ctx),
        KeyNames: RecordKeyNames{
            Time: timeKey,
            Msg:  msgKey,
            Lvl:  lvlKey,
        },
    }
-   runtime.Callers(3, r.CallPC[:])
+   runtime.Callers(l.CallSkip, r.CallPC[:])
    l.h.Log(&r)
}

that way the stack position could be adjusted

notzippy commented 7 years ago

Sorry just saw PR #128 - that would work great..