From 3b18a9842c73ffb18c68f7c86bdc18ce341ec777 Mon Sep 17 00:00:00 2001 From: David Banham Date: Thu, 27 Sep 2018 16:27:20 +1000 Subject: [PATCH] Add option for debug logging --- notifications.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/notifications.go b/notifications.go index 763eb4e..7debf62 100644 --- a/notifications.go +++ b/notifications.go @@ -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": "", @@ -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