Skip to content

Commit 8a870e4

Browse files
committed
fix race
1 parent 7e6f976 commit 8a870e4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

formatters/logstash/logstash.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ func (f *LogstashFormatter) Format(entry *logrus.Entry) ([]byte, error) {
2424

2525
fields["@version"] = 1
2626

27-
if f.TimestampFormat == "" {
28-
f.TimestampFormat = logrus.DefaultTimestampFormat
27+
timeStampFormat := f.TimestampFormat
28+
29+
if timeStampFormat == "" {
30+
timeStampFormat = logrus.DefaultTimestampFormat
2931
}
3032

31-
fields["@timestamp"] = entry.Time.Format(f.TimestampFormat)
33+
fields["@timestamp"] = entry.Time.Format(timeStampFormat)
3234

3335
// set message field
3436
v, ok := entry.Data["message"]

0 commit comments

Comments
 (0)