fix support for format
This commit is contained in:
parent
d13d851819
commit
45c66585ad
|
@ -36,7 +36,7 @@ func isFormatString(f interface{}) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
// 尝试使用空接口来格式化字符串
|
// 尝试使用空接口来格式化字符串
|
||||||
m := fmt.Sprintf(s, []interface{}{})
|
m := fmt.Sprintf(s, []interface{}{}...)
|
||||||
return strings.Index(m, "MISSING") != -1
|
return strings.Index(m, "MISSING") != -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,16 @@ func TestFormat(t *testing.T) {
|
||||||
},
|
},
|
||||||
want: "test_category : INFO - key: value",
|
want: "test_category : INFO - key: value",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "Info level with one format string",
|
||||||
|
logEvent: LogEvent{
|
||||||
|
Ts: time.Now(),
|
||||||
|
Category: "test_category",
|
||||||
|
Level: Info,
|
||||||
|
Data: []interface{}{"%s", "key"},
|
||||||
|
},
|
||||||
|
want: "test_category : INFO - key",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "Error level without format string",
|
name: "Error level without format string",
|
||||||
logEvent: LogEvent{
|
logEvent: LogEvent{
|
||||||
|
|
Loading…
Reference in New Issue