mirror of https://github.com/sirupsen/logrus.git
rename f.appendKeyValue to printKeyValue
printKeyValue is working similar like printColored, not using any fields of TextFormatter, should be a util func instead of a method of TextFormatter. Signed-off-by: Derek Che <drc@yahoo-inc.com>
This commit is contained in:
parent
d2f9ffa1d9
commit
03377c6168
|
@ -59,12 +59,12 @@ func (f *TextFormatter) Format(entry *Entry) ([]byte, error) {
|
||||||
printColored(b, entry, keys)
|
printColored(b, entry, keys)
|
||||||
} else {
|
} else {
|
||||||
if !f.DisableTimestamp {
|
if !f.DisableTimestamp {
|
||||||
f.appendKeyValue(b, "time", entry.Time.Format(time.RFC3339))
|
printKeyValue(b, "time", entry.Time.Format(time.RFC3339))
|
||||||
}
|
}
|
||||||
f.appendKeyValue(b, "level", entry.Level.String())
|
printKeyValue(b, "level", entry.Level.String())
|
||||||
f.appendKeyValue(b, "msg", entry.Message)
|
printKeyValue(b, "msg", entry.Message)
|
||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
f.appendKeyValue(b, key, entry.Data[key])
|
printKeyValue(b, key, entry.Data[key])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ func needsQuoting(text string) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *TextFormatter) appendKeyValue(b *bytes.Buffer, key, value interface{}) {
|
func printKeyValue(b *bytes.Buffer, key, value interface{}) {
|
||||||
switch value.(type) {
|
switch value.(type) {
|
||||||
case string:
|
case string:
|
||||||
if needsQuoting(value.(string)) {
|
if needsQuoting(value.(string)) {
|
||||||
|
|
Loading…
Reference in New Issue