Skip to content

Commit

Permalink
Add option for debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbanham committed Sep 27, 2018
1 parent 5a14145 commit 3b18a98
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,17 @@ import (

var svc *ses.SES
var testMode bool
var debugLogging bool

func init() {
if os.Getenv("TEST_MOCKS_ON") == "true" {
testMode = true
return
}
if os.Getenv("NOTIFICATIONS_LOG_LEVEL") == "debug" {
debugLogging = true
return
}
required_env.Ensure(map[string]string{
"AWS_ACCESS_KEY_ID": "",
"AWS_SECRET_ACCESS_KEY": "",
Expand All @@ -41,6 +46,9 @@ type Email struct {
}

func SendEmail(email Email) (err error) {
if debugLogging {
log.Printf("DEBUG notifications email: %+v \n", email)
}
if testMode {
log.Println("INFO notifications TESTMODE dropping email to", email.To, "from", email.From)
return
Expand Down

0 comments on commit 3b18a98

Please sign in to comment.