From f1addc29722ba9f7651bc42b4198d0944b66e7c4 Mon Sep 17 00:00:00 2001 From: Simon Eskildsen Date: Tue, 26 May 2015 09:02:13 -0400 Subject: [PATCH] formatter/json: fix possible race --- json_formatter.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/json_formatter.go b/json_formatter.go index dcc4f1d..2ad6dc5 100644 --- a/json_formatter.go +++ b/json_formatter.go @@ -24,11 +24,12 @@ func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { } prefixFieldClashes(data) - if f.TimestampFormat == "" { - f.TimestampFormat = DefaultTimestampFormat + timestampFormat := f.TimestampFormat + if timestampFormat == "" { + timestampFormat = DefaultTimestampFormat } - data["time"] = entry.Time.Format(f.TimestampFormat) + data["time"] = entry.Time.Format(timestampFormat) data["msg"] = entry.Message data["level"] = entry.Level.String()