We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6699a89 commit 61891c4Copy full SHA for 61891c4
entry.go
@@ -94,6 +94,19 @@ func (entry *Entry) String() (string, error) {
94
return str, nil
95
}
96
97
+// Add a caller field to the Entry.
98
+func (entry *Entry) WithCaller() *Entry {
99
+ frame := getCaller()
100
+ if frame != nil {
101
+ return entry.WithFields(Fields{
102
+ FieldKeyFile: fmt.Sprintf("%s:%d", frame.File, frame.Line),
103
+ FieldKeyFunc: frame.Function,
104
+ })
105
+ }
106
+
107
+ return entry
108
+}
109
110
// Add an error as single field (using the key defined in ErrorKey) to the Entry.
111
func (entry *Entry) WithError(err error) *Entry {
112
return entry.WithField(ErrorKey, err)
0 commit comments