mirror of https://github.com/sirupsen/logrus.git
only add a space between text entries if there is already content
So we don't have a trailing space at the end of each log line
This commit is contained in:
parent
b264ba77c3
commit
159e991025
|
@ -154,11 +154,12 @@ func (f *TextFormatter) needsQuoting(text string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *TextFormatter) appendKeyValue(b *bytes.Buffer, key string, value interface{}) {
|
func (f *TextFormatter) appendKeyValue(b *bytes.Buffer, key string, value interface{}) {
|
||||||
|
if b.String() != "" {
|
||||||
|
b.WriteByte(' ')
|
||||||
|
}
|
||||||
b.WriteString(key)
|
b.WriteString(key)
|
||||||
b.WriteByte('=')
|
b.WriteByte('=')
|
||||||
f.appendValue(b, value)
|
f.appendValue(b, value)
|
||||||
b.WriteByte(' ')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *TextFormatter) appendValue(b *bytes.Buffer, value interface{}) {
|
func (f *TextFormatter) appendValue(b *bytes.Buffer, value interface{}) {
|
||||||
|
|
|
@ -16,7 +16,7 @@ func TestFormatting(t *testing.T) {
|
||||||
value string
|
value string
|
||||||
expected 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 {
|
for _, tc := range testCases {
|
||||||
|
|
Loading…
Reference in New Issue