From 8a870e4f7bc0236aa47ad9bd71a311537022b083 Mon Sep 17 00:00:00 2001 From: Max Lavrenov Date: Fri, 15 Apr 2016 18:22:24 +0300 Subject: [PATCH] fix race --- formatters/logstash/logstash.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/formatters/logstash/logstash.go b/formatters/logstash/logstash.go index aad646a..2793af8 100644 --- a/formatters/logstash/logstash.go +++ b/formatters/logstash/logstash.go @@ -24,11 +24,13 @@ func (f *LogstashFormatter) Format(entry *logrus.Entry) ([]byte, error) { fields["@version"] = 1 - if f.TimestampFormat == "" { - f.TimestampFormat = logrus.DefaultTimestampFormat + timeStampFormat := f.TimestampFormat + + if timeStampFormat == "" { + timeStampFormat = logrus.DefaultTimestampFormat } - fields["@timestamp"] = entry.Time.Format(f.TimestampFormat) + fields["@timestamp"] = entry.Time.Format(timeStampFormat) // set message field v, ok := entry.Data["message"]