forked from mirror/logrus
Get right logrus package name
This commit is contained in:
parent
77ab282a06
commit
86a84a9d18
2
entry.go
2
entry.go
|
@ -185,7 +185,7 @@ func getCaller() *runtime.Frame {
|
||||||
callerInitOnce.Do(func() {
|
callerInitOnce.Do(func() {
|
||||||
pcs := make([]uintptr, 2)
|
pcs := make([]uintptr, 2)
|
||||||
_ = runtime.Callers(0, pcs)
|
_ = runtime.Callers(0, pcs)
|
||||||
logrusPackage = getPackageName(runtime.FuncForPC(pcs[1]).Name())
|
logrusPackage = getPackageName(funcName(pcs))
|
||||||
|
|
||||||
// now that we have the cache, we can skip a minimum count of known-logrus functions
|
// now that we have the cache, we can skip a minimum count of known-logrus functions
|
||||||
// XXX this is dubious, the number of frames may vary
|
// XXX this is dubious, the number of frames may vary
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
// +build go1.14
|
||||||
|
|
||||||
|
package logrus
|
||||||
|
|
||||||
|
import "runtime"
|
||||||
|
|
||||||
|
// funcName returns the function name that logrus calls
|
||||||
|
func funcName(pcs []uintptr) string {
|
||||||
|
return runtime.FuncForPC(pcs[0]).Name()
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
// +build !go1.14
|
||||||
|
|
||||||
|
package logrus
|
||||||
|
|
||||||
|
import "runtime"
|
||||||
|
|
||||||
|
// funcName returns the function name that logrus calls
|
||||||
|
func funcName(pcs []uintptr) string {
|
||||||
|
return runtime.FuncForPC(pcs[1]).Name()
|
||||||
|
}
|
Loading…
Reference in New Issue