Skip to content

Commit

Permalink
Add some debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
devinbhatt committed Feb 17, 2024
1 parent e2e4f91 commit ded35fe
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions flagbot.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"os"
"os/signal"
"regexp"
"strings"
"syscall"
"time"

Expand All @@ -31,12 +32,20 @@ var (

func init() {
// Setup logging
logLevel := os.Getenv("LOG_LEVEL")
if logLevel == "" {
logLevel = "info"
}
level, err := log.ParseLevel(strings.ToLower(logLevel))
if err != nil {
log.Fatalf("Invalid log level: %s", logLevel)
}
log.SetOutput(os.Stdout)
log.SetFormatter(&log.TextFormatter{
FullTimestamp: true,
DisableColors: true,
})
log.SetLevel(log.InfoLevel)
log.SetLevel(level)

// Parse out command line arguments
flag.StringVar(&token, "t", "", "Bot Token")
Expand All @@ -53,7 +62,6 @@ func init() {
}

// Load files into their respective variables
var err error
gifSlice, err = readFileToSlice(configurationPath + "/gifs.txt")
if err != nil {
log.WithFields(log.Fields{
Expand Down Expand Up @@ -112,7 +120,7 @@ func main() {
sc := make(chan os.Signal, 1)
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
<-sc

log.Debug("Exiting...")
// Cleanly close down the Discord session.
dg.Close()
}
Expand All @@ -129,6 +137,7 @@ func ready(s *discordgo.Session, event *discordgo.Ready) {
// messageCreate is a hook for any new discord messages. Any time a message is created
// in a monitored channel, this function is run against it
func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
log.Debug("Got message", m.Content)
go flagCheck(s, m)
}

Expand Down

0 comments on commit ded35fe

Please sign in to comment.