| 1 |
package gelf |
| 2 |
|
| 3 |
import ( |
| 4 |
"runtime" |
| 5 |
"strings" |
| 6 |
) |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
func getCaller(callDepth int, suffixesToIgnore ...string) (file string, line int) { |
| 15 |
|
| 16 |
callDepth++ |
| 17 |
outer: |
| 18 |
for { |
| 19 |
var ok bool |
| 20 |
_, file, line, ok = runtime.Caller(callDepth) |
| 21 |
if !ok { |
| 22 |
file = "???" |
| 23 |
line = 0 |
| 24 |
break |
| 25 |
} |
| 26 |
|
| 27 |
for _, s := range suffixesToIgnore { |
| 28 |
if strings.HasSuffix(file, s) { |
| 29 |
callDepth++ |
| 30 |
continue outer |
| 31 |
} |
| 32 |
} |
| 33 |
break |
| 34 |
} |
| 35 |
return |
| 36 |
} |
| 37 |
|
| 38 |
func getCallerIgnoringLogMulti(callDepth int) (string, int) { |
| 39 |
|
| 40 |
return getCaller(callDepth+1, "/pkg/log/log.go", "/pkg/io/multi.go") |
| 41 |
} |