Fix go1.12 test regression
Breakage is due to this change in go 1.12: Tracebacks, runtime.Caller, and runtime.Callers no longer include compiler-generated initialization functions. Doing a traceback during the initialization of a global variable will now show a function named PKG.init.ializers. Fix #137
This commit is contained in:
parent
299ff038c1
commit
6d6350a511
|
@ -4,6 +4,8 @@ go:
|
||||||
- "1.8"
|
- "1.8"
|
||||||
- "1.9"
|
- "1.9"
|
||||||
- "1.10"
|
- "1.10"
|
||||||
|
- "1.11"
|
||||||
|
- "1.12"
|
||||||
- "master"
|
- "master"
|
||||||
matrix:
|
matrix:
|
||||||
allow_failures:
|
allow_failures:
|
||||||
|
|
|
@ -350,8 +350,8 @@ func (c Context) Interface(key string, i interface{}) Context {
|
||||||
type callerHook struct{}
|
type callerHook struct{}
|
||||||
|
|
||||||
func (ch callerHook) Run(e *Event, level Level, msg string) {
|
func (ch callerHook) Run(e *Event, level Level, msg string) {
|
||||||
// Three extra frames to skip (added by hook infra).
|
// Extra frames to skip (added by hook infra).
|
||||||
e.caller(CallerSkipFrameCount + 3)
|
e.caller(CallerSkipFrameCount + contextCallerSkipFrameCount)
|
||||||
}
|
}
|
||||||
|
|
||||||
var ch = callerHook{}
|
var ch = callerHook{}
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
// +build go1.12
|
||||||
|
|
||||||
|
package zerolog
|
||||||
|
|
||||||
|
// Since go 1.12, some auto generated init functions are hidden from
|
||||||
|
// runtime.Caller.
|
||||||
|
const contextCallerSkipFrameCount = 2
|
|
@ -0,0 +1,5 @@
|
||||||
|
// +build !go1.12
|
||||||
|
|
||||||
|
package zerolog
|
||||||
|
|
||||||
|
const contextCallerSkipFrameCount = 3
|
Loading…
Reference in New Issue