From 0998f68ad5703121c431eb50e97b65b7de234df5 Mon Sep 17 00:00:00 2001 From: Simon Eskildsen Date: Fri, 14 Mar 2014 13:32:49 -0400 Subject: [PATCH] text_formatter: ensure quoting of strings --- text_formatter.go | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/text_formatter.go b/text_formatter.go index 3d2205a..5c50c91 100644 --- a/text_formatter.go +++ b/text_formatter.go @@ -70,22 +70,9 @@ func (f *TextFormatter) Format(entry *Entry) ([]byte, error) { } func (f *TextFormatter) AppendKeyValue(serialized []byte, key, value interface{}) []byte { - return append(serialized, []byte(fmt.Sprintf("%v=%v ", key, value))...) + if _, ok := value.(string); ok { + return append(serialized, []byte(fmt.Sprintf("%v='%v' ", key, value))...) + } else { + return append(serialized, []byte(fmt.Sprintf("%v=%v ", key, value))...) + } } - -// func (f *TextFormatter) ToString(value interface{}, escapeStrings bool) string { -// switch value.(type) { -// default: -// if escapeStrings { -// return fmt.Sprintf("'%s'", value) -// } else { -// return fmt.Sprintf("%s", value) -// } -// case int: -// return fmt.Sprintf("%s", strconv.Itoa(value.(int))) -// case uint64: -// return fmt.Sprintf("%s", strconv.FormatUint(value.(uint64), 10)) -// case bool: -// return fmt.Sprintf("%s", strconv.FormatBool(value.(bool))) -// } -// }