This is to not silently overwrite `time`, `msg` and `level` fields when dumping it. If this code wasn't there doing: logrus.WithField("level", 1).Info("hello") Would silently drop the user provided level. Instead with this code it'll logged as: {"level": "info", "fields.level": 1, "msg": "hello
(data log.Fields)
| 197 | // It's not exported because it's still using Data in an opinionated way. It's to |
| 198 | // avoid code duplication between the two default formatters. |
| 199 | func prefixFieldClashes(data log.Fields) { |
| 200 | if t, ok := data["time"]; ok { |
| 201 | data["fields.time"] = t |
| 202 | } |
| 203 | |
| 204 | if m, ok := data["msg"]; ok { |
| 205 | data["fields.msg"] = m |
| 206 | } |
| 207 | |
| 208 | if level, ok := data["level"]; ok { |
| 209 | data["fields.level"] = level |
| 210 | } |
| 211 | } |