Skip to content

Commit 8d17041

Browse files
yhabteabjulianbrost
authored andcommitted
Replace log.Printf in Plugin#Send() methods with a proper logging
1 parent 496119d commit 8d17041

File tree

3 files changed

+4
-10
lines changed

3 files changed

+4
-10
lines changed

internal/channel/email.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"github.com/icinga/icinga-notifications/internal/contracts"
88
"github.com/icinga/icinga-notifications/internal/event"
99
"github.com/icinga/icinga-notifications/internal/recipient"
10-
"log"
1110
"net"
1211
"net/smtp"
1312
"os"
@@ -58,8 +57,6 @@ func NewEMail(config string) (Plugin, error) {
5857
}
5958

6059
func (e *EMail) Send(contact *recipient.Contact, incident contracts.Incident, event *event.Event, icingaweb2Url string) error {
61-
log.Printf("email: contact=%v incident=%v event=%v", contact, incident, event)
62-
6360
var to []string
6461
for _, address := range contact.Addresses {
6562
if address.Type == "email" {
@@ -82,8 +79,6 @@ func (e *EMail) Send(contact *recipient.Contact, incident contracts.Incident, ev
8279
return err
8380
}
8481

85-
log.Printf("Successfully sent mail to user %s\n", contact.FullName)
86-
8782
return nil
8883
}
8984

internal/channel/rocketchat.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"github.com/icinga/icinga-notifications/internal/contracts"
99
"github.com/icinga/icinga-notifications/internal/event"
1010
"github.com/icinga/icinga-notifications/internal/recipient"
11-
"log"
1211
"net/http"
1312
"time"
1413
)
@@ -33,8 +32,6 @@ func NewRocketChat(config string) (Plugin, error) {
3332
}
3433

3534
func (r *RocketChat) Send(contact *recipient.Contact, incident contracts.Incident, event *event.Event, icingaweb2Url string) error {
36-
log.Printf("rocketchat: contact=%v incident=%v event=%v", contact, incident, event)
37-
3835
var output bytes.Buffer
3936
_, _ = fmt.Fprintf(&output, "[#%d] %s %s is %s\n\n", incident.ID(), event.Type, incident.ObjectDisplayName(), event.Severity.String())
4037

@@ -86,7 +83,5 @@ func (r *RocketChat) Send(contact *recipient.Contact, incident contracts.Inciden
8683
return errors.New(resp.Status)
8784
}
8885

89-
log.Printf("Successfully sent a rocketchat message to user %s\n", contact.FullName)
90-
9186
return nil
9287
}

internal/incident/incident.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,10 @@ func (i *Incident) notifyContacts(ev *event.Event, causedBy types.Int) error {
473473
i.logger.Errorw("Failed to send via channel", zap.String("type", chType), zap.Error(err))
474474
continue
475475
}
476+
477+
i.logger.Infow(
478+
"Successfully sent a message via channel", zap.String("type", chType), zap.String("contact", contact.String()),
479+
)
476480
}
477481
}
478482

0 commit comments

Comments
 (0)