taken from https://github.com/VividCortex/trace
()
| 127 | |
| 128 | // taken from https://github.com/VividCortex/trace |
| 129 | func getPosition() (fn, dir, file string, line int) { |
| 130 | pc, file, line, ok := runtime.Caller(2) |
| 131 | if !ok { |
| 132 | return "", "", "", 0 |
| 133 | } |
| 134 | |
| 135 | dirname, filename := filepath.Base(filepath.Dir(file)), filepath.Base(file) |
| 136 | |
| 137 | Func := runtime.FuncForPC(pc) |
| 138 | |
| 139 | return path.Base(Func.Name()), dirname, filename, line |
| 140 | } |
| 141 | |
| 142 | func checkFilter(filter map[string]bool, key string) bool { |
| 143 | // check if key is enabled directly |