adds logging to sentry of api failled api calls

This commit is contained in:
Seraphim Strub 2023-04-23 00:51:02 +02:00
parent df441014ed
commit a3349fe7b1

View file

@ -50,8 +50,6 @@ func main() {
// Flush buffered events before the program terminates. // Flush buffered events before the program terminates.
defer sentry.Flush(2 * time.Second) defer sentry.Flush(2 * time.Second)
sentry.CaptureMessage("DEBUG: dealsbot started")
log.Printf("INFO: starting dealsbot...") log.Printf("INFO: starting dealsbot...")
log.Printf("INFO: disgo version: %v", disgo.Version) log.Printf("INFO: disgo version: %v", disgo.Version)
@ -71,15 +69,16 @@ func main() {
case <-ticker.C: case <-ticker.C:
var apis []api.Api var apis []api.Api
apis = append(apis, api.NewUbsioftApi(), api.NewEpicApi(), api.NewSteamApi(), api.NewGogApi(), api.NewHumbleBundleApi()) apis = append(apis, api.NewUbsioftApi(), api.NewEpicApi(), api.NewSteamApi(), api.NewGogApi(), api.NewHumbleBundleApi())
for _, api := range apis { for _, a := range apis {
err := api.Load() err := a.Load()
if err != nil { if err != nil {
sentry.CaptureException(fmt.Errorf("ERROR: loading from api: %w", err))
log.Printf("ERROR: %v", err) log.Printf("ERROR: %v", err)
} }
} }
var deals []api.Deal var deals []api.Deal
for _, api := range apis { for _, a := range apis {
apiDeals := api.Get() apiDeals := a.Get()
deals = append(deals, apiDeals...) deals = append(deals, apiDeals...)
} }
@ -116,6 +115,7 @@ func main() {
}() }()
log.Printf("INFO: dealsbot is now running. Press CTRL-C to exit.") log.Printf("INFO: dealsbot is now running. Press CTRL-C to exit.")
sentry.CaptureMessage("DEBUG: dealsbot started")
s := make(chan os.Signal, 1) s := make(chan os.Signal, 1)
signal.Notify(s, syscall.SIGINT, syscall.SIGTERM, os.Interrupt) signal.Notify(s, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)
<-s <-s