From acf1c0d583f42c12720dd1b63dc8f8a729695a17 Mon Sep 17 00:00:00 2001 From: Antoine Grondin Date: Fri, 3 Oct 2014 11:58:24 -0400 Subject: [PATCH] textformatter: errors should be in quotes like strings are --- text_formatter.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/text_formatter.go b/text_formatter.go index 2ab0139..fc0a408 100644 --- a/text_formatter.go +++ b/text_formatter.go @@ -53,11 +53,11 @@ func (f *TextFormatter) Format(entry *Entry) ([]byte, error) { if isColored { printColored(b, entry, keys) } else { - f.AppendKeyValue(b, "time", entry.Time.Format(time.RFC3339)) - f.AppendKeyValue(b, "level", entry.Level.String()) - f.AppendKeyValue(b, "msg", entry.Message) + f.appendKeyValue(b, "time", entry.Time.Format(time.RFC3339)) + f.appendKeyValue(b, "level", entry.Level.String()) + f.appendKeyValue(b, "msg", entry.Message) for _, key := range keys { - f.AppendKeyValue(b, key, entry.Data[key]) + f.appendKeyValue(b, key, entry.Data[key]) } } @@ -85,10 +85,11 @@ func printColored(b *bytes.Buffer, entry *Entry, keys []string) { } } -func (f *TextFormatter) AppendKeyValue(b *bytes.Buffer, key, value interface{}) { - if _, ok := value.(string); ok { +func (f *TextFormatter) appendKeyValue(b *bytes.Buffer, key, value interface{}) { + switch value.(type) { + case string, error: fmt.Fprintf(b, "%v=%q ", key, value) - } else { + default: fmt.Fprintf(b, "%v=%v ", key, value) } }