mirror of https://github.com/sirupsen/logrus.git
text_formatter: ensure quoting of strings
This commit is contained in:
parent
52eb1c0f57
commit
0998f68ad5
|
@ -70,22 +70,9 @@ func (f *TextFormatter) Format(entry *Entry) ([]byte, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *TextFormatter) AppendKeyValue(serialized []byte, key, value interface{}) []byte {
|
func (f *TextFormatter) AppendKeyValue(serialized []byte, key, value interface{}) []byte {
|
||||||
|
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))...)
|
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)))
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
Loading…
Reference in New Issue