mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
fix notify args filtering
This commit is contained in:
parent
e17535e651
commit
fc0457cefe
|
@ -51,7 +51,8 @@ func (m *Notifiability) AddNotifier(notifier Notifier) {
|
|||
|
||||
func (m *Notifiability) Notify(obj interface{}, args ...interface{}) {
|
||||
if str, ok := obj.(string); ok {
|
||||
logrus.Infof(str, args...)
|
||||
simpleArgs := filterSimpleArgs(args)
|
||||
logrus.Infof(str, simpleArgs...)
|
||||
}
|
||||
|
||||
for _, n := range m.notifiers {
|
||||
|
@ -64,3 +65,14 @@ func (m *Notifiability) NotifyTo(channel string, obj interface{}, args ...interf
|
|||
n.NotifyTo(channel, obj, args...)
|
||||
}
|
||||
}
|
||||
|
||||
func filterSimpleArgs(args []interface{}) (simpleArgs []interface{}) {
|
||||
for _, arg := range args {
|
||||
switch arg.(type) {
|
||||
case int, int64, int32, uint64, uint32, string, []byte, float64, float32:
|
||||
simpleArgs = append(simpleArgs, arg)
|
||||
}
|
||||
}
|
||||
|
||||
return simpleArgs
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user