From 42c3770231f12107f07fff8a7d629e34213bdaba Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Thu, 8 Feb 2024 12:35:52 +0800 Subject: [PATCH] :test_tube: Add more debug logs --- pkg/cmd/main.go | 2 ++ pkg/services/notifications.go | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/cmd/main.go b/pkg/cmd/main.go index c3009a6..35f9813 100644 --- a/pkg/cmd/main.go +++ b/pkg/cmd/main.go @@ -42,6 +42,8 @@ func main() { // All the things are optional so when error occurred the server won't crash if err := external.SetupFirebase(viper.GetString("external.firebase.credentials")); err != nil { log.Error().Err(err).Msg("An error occurred when starting firebase communicating...") + } else { + log.Info().Msg("Successfully setup firebase communication.") } // Server diff --git a/pkg/services/notifications.go b/pkg/services/notifications.go index 7eaf9c2..f0e0659 100644 --- a/pkg/services/notifications.go +++ b/pkg/services/notifications.go @@ -75,8 +75,13 @@ func NewNotification( Token: subscriber.DeviceID, } - if _, err = client.Send(ctx, message); err != nil { + if response, err := client.Send(ctx, message); err != nil { log.Warn().Err(err).Msg("An error occurred when notify subscriber though firebase FCM...") + } else { + log.Debug(). + Str("response", response). + Int("subscriber", int(subscriber.ID)). + Msg("Notified to subscriber though firebase FCM.") } } }