add file and line number in output when report caller is enabled

This commit is contained in:
David Bariod
2018-10-28 17:39:39 +01:00
parent fa01b53097
commit d2654b752f
4 changed files with 22 additions and 4 deletions
+5
View File
@@ -10,6 +10,7 @@ const (
FieldKeyTime = "time"
FieldKeyLogrusError = "logrus_error"
FieldKeyFunc = "func"
FieldKeyFile = "file"
)
// The Formatter interface is used to implement a custom Formatter. It takes an
@@ -69,5 +70,9 @@ func prefixFieldClashes(data Fields, fieldMap FieldMap, reportCaller bool) {
if l, ok := data[funcKey]; ok {
data["fields."+funcKey] = l
}
fileKey := fieldMap.resolve(FieldKeyFile)
if l, ok := data[fileKey]; ok {
data["fields."+fileKey] = l
}
}
}