diff --git a/.travis.yml b/.travis.yml index 64d202a..70b67c9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,8 @@ go: - "1.8" - "1.9" - "1.10" +- "1.11" +- "1.12" - "master" matrix: allow_failures: diff --git a/context.go b/context.go index f807802..9eff31a 100644 --- a/context.go +++ b/context.go @@ -350,8 +350,8 @@ func (c Context) Interface(key string, i interface{}) Context { type callerHook struct{} func (ch callerHook) Run(e *Event, level Level, msg string) { - // Three extra frames to skip (added by hook infra). - e.caller(CallerSkipFrameCount + 3) + // Extra frames to skip (added by hook infra). + e.caller(CallerSkipFrameCount + contextCallerSkipFrameCount) } var ch = callerHook{} diff --git a/go112.go b/go112.go new file mode 100644 index 0000000..e7b5a1b --- /dev/null +++ b/go112.go @@ -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 diff --git a/not_go112.go b/not_go112.go new file mode 100644 index 0000000..4c43c9e --- /dev/null +++ b/not_go112.go @@ -0,0 +1,5 @@ +// +build !go1.12 + +package zerolog + +const contextCallerSkipFrameCount = 3