diff --git a/text_formatter.go b/text_formatter.go index cf3f17f..ec8d473 100644 --- a/text_formatter.go +++ b/text_formatter.go @@ -154,11 +154,12 @@ func (f *TextFormatter) needsQuoting(text string) bool { } func (f *TextFormatter) appendKeyValue(b *bytes.Buffer, key string, value interface{}) { - + if b.String() != "" { + b.WriteByte(' ') + } b.WriteString(key) b.WriteByte('=') f.appendValue(b, value) - b.WriteByte(' ') } func (f *TextFormatter) appendValue(b *bytes.Buffer, value interface{}) { diff --git a/text_formatter_test.go b/text_formatter_test.go index 7f7b78c..d93b931 100644 --- a/text_formatter_test.go +++ b/text_formatter_test.go @@ -16,7 +16,7 @@ func TestFormatting(t *testing.T) { value string expected string }{ - {`foo`, "time=\"0001-01-01T00:00:00Z\" level=panic test=foo \n"}, + {`foo`, "time=\"0001-01-01T00:00:00Z\" level=panic test=foo\n"}, } for _, tc := range testCases {