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
+1
View File
@@ -83,6 +83,7 @@ func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) {
data[f.FieldMap.resolve(FieldKeyLevel)] = entry.Level.String()
if entry.HasCaller() {
data[f.FieldMap.resolve(FieldKeyFunc)] = entry.Caller.Function
data[f.FieldMap.resolve(FieldKeyFile)] = fmt.Sprintf("%s:%d", entry.Caller.File, entry.Caller.Line)
}
var b *bytes.Buffer