mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 16:25:16 +00:00
add fields to slack notifier logs
This commit is contained in:
parent
b22e0370b3
commit
c96845ff6a
|
@ -4,7 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/slack-go/slack"
|
"github.com/slack-go/slack"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -69,13 +69,15 @@ func (n *Notifier) NotifyTo(channel, format string, args ...interface{}) {
|
||||||
nonSlackArgs = args[:slackArgsOffset]
|
nonSlackArgs = args[:slackArgsOffset]
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Infof(format, nonSlackArgs...)
|
log.Infof(format, nonSlackArgs...)
|
||||||
|
|
||||||
_, _, err := n.client.PostMessageContext(context.Background(), channel,
|
_, _, err := n.client.PostMessageContext(context.Background(), channel,
|
||||||
slack.MsgOptionText(fmt.Sprintf(format, nonSlackArgs...), true),
|
slack.MsgOptionText(fmt.Sprintf(format, nonSlackArgs...), true),
|
||||||
slack.MsgOptionAttachments(slackAttachments...))
|
slack.MsgOptionAttachments(slackAttachments...))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Errorf("slack error: %s", err.Error())
|
log.WithError(err).
|
||||||
|
WithField("channel", channel).
|
||||||
|
Errorf("slack error: %s", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue
Block a user