formatter/json: fix possible race

This commit is contained in:
Simon Eskildsen 2015-05-26 09:02:13 -04:00
parent 092eda23b5
commit f1addc2972
1 changed files with 4 additions and 3 deletions

View File

@ -24,11 +24,12 @@ func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) {
} }
prefixFieldClashes(data) prefixFieldClashes(data)
if f.TimestampFormat == "" { timestampFormat := f.TimestampFormat
f.TimestampFormat = DefaultTimestampFormat if timestampFormat == "" {
timestampFormat = DefaultTimestampFormat
} }
data["time"] = entry.Time.Format(f.TimestampFormat) data["time"] = entry.Time.Format(timestampFormat)
data["msg"] = entry.Message data["msg"] = entry.Message
data["level"] = entry.Level.String() data["level"] = entry.Level.String()