Add debug logging for incoming alerts

This commit is contained in:
Fabian Reinartz 2015-09-29 11:58:30 +02:00
parent eeeeeea3d8
commit 7224f33c5b
2 changed files with 8 additions and 1 deletions

View File

@ -29,6 +29,8 @@ type Dispatcher struct {
done chan struct{}
ctx context.Context
cancel func()
log log.Logger
}
// NewDispatcher returns a new Dispatcher.
@ -36,6 +38,7 @@ func NewDispatcher(ap provider.Alerts, n Notifier) *Dispatcher {
return &Dispatcher{
alerts: ap,
notifier: n,
log: log.With("component", "dispatcher"),
}
}
@ -72,6 +75,8 @@ func (d *Dispatcher) run(it provider.AlertIterator) {
for {
select {
case alert := <-it.Next():
d.log.With("alert", alert).Debug("Received alert")
// Log errors but keep trying
if err := it.Err(); err != nil {
log.Errorf("Error on alert update: %s", err)

View File

@ -83,5 +83,7 @@ func main() {
term := make(chan os.Signal)
signal.Notify(term, os.Interrupt, syscall.SIGTERM)
<-term
log.Warn("Received SIGTERM, exiting gracefully...")
log.Infoln("Received SIGTERM, exiting gracefully...")
os.Exit(0)
}