logrusFrame adds the file and func to the logrus.Entry, for use in logging errors
(entry *logrus.Entry, frame runtime.Frame, module string)
| 96 | // logrusFrame adds the file and func to the logrus.Entry, |
| 97 | // for use in logging errors |
| 98 | func logrusFrame(entry *logrus.Entry, frame runtime.Frame, module string) { |
| 99 | if frame.File != "" { |
| 100 | filename := strings.TrimPrefix(frame.File, module) |
| 101 | fileline := fmt.Sprintf("%s:%d", filename, frame.Line) |
| 102 | if v, ok := entry.Data["file"]; ok { |
| 103 | entry.Data["fields.file"] = v |
| 104 | } |
| 105 | entry.Data["file"] = fileline |
| 106 | } |
| 107 | if frame.Function != "" { |
| 108 | _, function := filepath.Split(frame.Function) |
| 109 | if v, ok := entry.Data["func"]; ok { |
| 110 | entry.Data["fields.func"] = v |
| 111 | } |
| 112 | entry.Data["func"] = function |
| 113 | } |
| 114 | } |