From fed288f501d501dadb5d064c1b559dcdf7288b0f Mon Sep 17 00:00:00 2001 From: Seraphim Strub Date: Sun, 23 Apr 2023 01:23:52 +0200 Subject: [PATCH] remove dsn and add logging to all --- cmd/dealsbot/main.go | 10 +++++++--- cmd/domaincheckbot/main.go | 24 +++++++++++++++++++++++- cmd/funbot/main.go | 28 +++++++++++++++++++++++++++- cmd/tempbot/main.go | 25 +++++++++++++++++++++++++ cmd/vcbot/main.go | 28 +++++++++++++++++++++++++++- cmd/welcomebot/main.go | 26 ++++++++++++++++++++++++++ 6 files changed, 135 insertions(+), 6 deletions(-) diff --git a/cmd/dealsbot/main.go b/cmd/dealsbot/main.go index 50af72c..b1aa40d 100644 --- a/cmd/dealsbot/main.go +++ b/cmd/dealsbot/main.go @@ -42,7 +42,7 @@ func main() { err := sentry.Init(sentry.ClientOptions{ // Either set your DSN here or set the SENTRY_DSN environment variable. - Dsn: "https://0282823b5ee14546a4c154c129109a31@sentry.rvo.one/2", + //Dsn: "", // Set TracesSampleRate to 1.0 to capture 100% // of transactions for performance monitoring. // We recommend adjusting this value in production, @@ -119,8 +119,12 @@ func main() { } }() - log.Printf("INFO: dealsbot is now running. Press CTRL-C to exit.") - sentry.CaptureMessage("DEBUG: dealsbot started") + log.Printf("INFO: dealsbot (%v) is now running. Press CTRL-C to exit.", release) + sentry.ConfigureScope(func(scope *sentry.Scope) { + scope.SetLevel(sentry.LevelDebug) + sentry.CaptureMessage("DEBUG: dealsbot started") + }) + s := make(chan os.Signal, 1) signal.Notify(s, syscall.SIGINT, syscall.SIGTERM, os.Interrupt) <-s diff --git a/cmd/domaincheckbot/main.go b/cmd/domaincheckbot/main.go index 360d63d..6823a8d 100644 --- a/cmd/domaincheckbot/main.go +++ b/cmd/domaincheckbot/main.go @@ -10,6 +10,7 @@ import ( "github.com/disgoorg/disgo/rest" "github.com/disgoorg/disgo/webhook" "github.com/disgoorg/snowflake/v2" + "github.com/getsentry/sentry-go" "grow.rievo.dev/discordBots/cmd/domaincheckbot/config" "grow.rievo.dev/discordBots/cmd/domaincheckbot/dns" "grow.rievo.dev/discordBots/cmd/domaincheckbot/repository" @@ -28,7 +29,26 @@ var ( // TODO: clear db from domains removed from json +// sentry +var release string + func main() { + + err := sentry.Init(sentry.ClientOptions{ + // Either set your DSN here or set the SENTRY_DSN environment variable. + //Dsn: "", + // Set TracesSampleRate to 1.0 to capture 100% + // of transactions for performance monitoring. + // We recommend adjusting this value in production, + TracesSampleRate: 1.0, + Release: release, + }) + if err != nil { + log.Fatalf("sentry.Init: %s", err) + } + // Flush buffered events before the program terminates. + defer sentry.Flush(2 * time.Second) + log.Printf("INFO: starting domainCheck...") log.Printf("INFO: disgo version: %v", disgo.Version) @@ -66,7 +86,9 @@ func main() { } }() - log.Printf("INFO: domainCheck is now running. Press CTRL-C to exit.") + log.Printf("INFO: domaincheckbot (%v) is now running. Press CTRL-C to exit.", release) + sentry.CaptureMessage("DEBUG: domaincheckbot started") + s := make(chan os.Signal, 1) signal.Notify(s, syscall.SIGINT, syscall.SIGTERM, os.Interrupt) <-s diff --git a/cmd/funbot/main.go b/cmd/funbot/main.go index 69d9254..f43333b 100644 --- a/cmd/funbot/main.go +++ b/cmd/funbot/main.go @@ -6,6 +6,7 @@ import ( "github.com/disgoorg/disgo/bot" "github.com/disgoorg/disgo/cache" "github.com/disgoorg/disgo/gateway" + "github.com/getsentry/sentry-go" "grow.rievo.dev/discordBots/cmd/funbot/command" "grow.rievo.dev/discordBots/cmd/funbot/config" "log" @@ -13,9 +14,29 @@ import ( "os/signal" "strings" "syscall" + "time" ) +// sentry +var release string + func main() { + + err := sentry.Init(sentry.ClientOptions{ + // Either set your DSN here or set the SENTRY_DSN environment variable. + //Dsn: "", + // Set TracesSampleRate to 1.0 to capture 100% + // of transactions for performance monitoring. + // We recommend adjusting this value in production, + TracesSampleRate: 1.0, + Release: release, + }) + if err != nil { + log.Fatalf("sentry.Init: %s", err) + } + // Flush buffered events before the program terminates. + defer sentry.Flush(2 * time.Second) + log.Printf("INFO: starting funbot...") log.Printf("INFO: disgo version: %v", disgo.Version) @@ -66,7 +87,12 @@ func main() { log.Fatal("error while connecting to gateway: ", err) } - log.Printf("INFO: funbot is now running. Press CTRL-C to exit.") + log.Printf("INFO: funbot (%v) is now running. Press CTRL-C to exit.", release) + sentry.ConfigureScope(func(scope *sentry.Scope) { + scope.SetLevel(sentry.LevelDebug) + sentry.CaptureMessage("DEBUG: funbot started") + }) + s := make(chan os.Signal, 1) signal.Notify(s, syscall.SIGINT, syscall.SIGTERM, os.Interrupt) <-s diff --git a/cmd/tempbot/main.go b/cmd/tempbot/main.go index 3bc349e..e80a923 100644 --- a/cmd/tempbot/main.go +++ b/cmd/tempbot/main.go @@ -7,6 +7,7 @@ import ( "github.com/disgoorg/disgo/cache" "github.com/disgoorg/disgo/gateway" "github.com/disgoorg/snowflake/v2" + "github.com/getsentry/sentry-go" "log" "os" "os/signal" @@ -20,7 +21,26 @@ var ( channelTempID snowflake.ID ) +// sentry +var release string + func main() { + + err := sentry.Init(sentry.ClientOptions{ + // Either set your DSN here or set the SENTRY_DSN environment variable. + //Dsn: "", + // Set TracesSampleRate to 1.0 to capture 100% + // of transactions for performance monitoring. + // We recommend adjusting this value in production, + TracesSampleRate: 1.0, + Release: release, + }) + if err != nil { + log.Fatalf("sentry.Init: %s", err) + } + // Flush buffered events before the program terminates. + defer sentry.Flush(2 * time.Second) + log.Printf("INFO: starting tempbot...") log.Printf("INFO: disgo version: %v", disgo.Version) @@ -95,6 +115,11 @@ func main() { }() log.Printf("INFO: tempbot is now running. Press CTRL-C to exit.") + sentry.ConfigureScope(func(scope *sentry.Scope) { + scope.SetLevel(sentry.LevelDebug) + sentry.CaptureMessage("DEBUG: tempbot started") + }) + s := make(chan os.Signal, 1) signal.Notify(s, syscall.SIGINT, syscall.SIGTERM, os.Interrupt) <-s diff --git a/cmd/vcbot/main.go b/cmd/vcbot/main.go index 61138e2..a5343c0 100644 --- a/cmd/vcbot/main.go +++ b/cmd/vcbot/main.go @@ -6,19 +6,40 @@ import ( "github.com/disgoorg/disgo/bot" "github.com/disgoorg/disgo/cache" "github.com/disgoorg/disgo/gateway" + "github.com/getsentry/sentry-go" "grow.rievo.dev/discordBots/cmd/vcbot/config" "grow.rievo.dev/discordBots/cmd/vcbot/event" "log" "os" "os/signal" "syscall" + "time" ) +// sentry +var release string + func main() { + + err := sentry.Init(sentry.ClientOptions{ + // Either set your DSN here or set the SENTRY_DSN environment variable. + //Dsn: "", + // Set TracesSampleRate to 1.0 to capture 100% + // of transactions for performance monitoring. + // We recommend adjusting this value in production, + TracesSampleRate: 1.0, + Release: release, + }) + if err != nil { + log.Fatalf("sentry.Init: %s", err) + } + // Flush buffered events before the program terminates. + defer sentry.Flush(2 * time.Second) + log.Printf("INFO: starting vcbot...") log.Printf("INFO: disgo version: %v", disgo.Version) - err := config.LoadAppleList() + err = config.LoadAppleList() if err != nil { log.Fatal(err) return @@ -66,6 +87,11 @@ func main() { } log.Printf("ERROR: vcbot is now running. Press CTRL-C to exit.") + sentry.ConfigureScope(func(scope *sentry.Scope) { + scope.SetLevel(sentry.LevelDebug) + sentry.CaptureMessage("DEBUG: vcbot started") + }) + s := make(chan os.Signal, 1) signal.Notify(s, syscall.SIGINT, syscall.SIGTERM, os.Interrupt) <-s diff --git a/cmd/welcomebot/main.go b/cmd/welcomebot/main.go index d0058d8..48946f9 100644 --- a/cmd/welcomebot/main.go +++ b/cmd/welcomebot/main.go @@ -6,15 +6,36 @@ import ( "github.com/disgoorg/disgo/bot" "github.com/disgoorg/disgo/cache" "github.com/disgoorg/disgo/gateway" + "github.com/getsentry/sentry-go" "grow.rievo.dev/discordBots/cmd/welcomebot/config" "grow.rievo.dev/discordBots/cmd/welcomebot/event" "log" "os" "os/signal" "syscall" + "time" ) +// sentry +var release string + func main() { + + err := sentry.Init(sentry.ClientOptions{ + // Either set your DSN here or set the SENTRY_DSN environment variable. + //Dsn: "", + // Set TracesSampleRate to 1.0 to capture 100% + // of transactions for performance monitoring. + // We recommend adjusting this value in production, + TracesSampleRate: 1.0, + Release: release, + }) + if err != nil { + log.Fatalf("sentry.Init: %s", err) + } + // Flush buffered events before the program terminates. + defer sentry.Flush(2 * time.Second) + log.Printf("INFO: starting welcomebot...") log.Printf("INFO: disgo version: %v", disgo.Version) @@ -73,6 +94,11 @@ func main() { } log.Printf("INFO: welcomebot is now running. Press CTRL-C to exit.") + sentry.ConfigureScope(func(scope *sentry.Scope) { + scope.SetLevel(sentry.LevelDebug) + sentry.CaptureMessage("DEBUG: welcomebot started") + }) + s := make(chan os.Signal, 1) signal.Notify(s, syscall.SIGINT, syscall.SIGTERM, os.Interrupt) <-s