mirror of
https://github.com/mgerb/go-discord-bot
synced 2026-01-11 17:42:48 +00:00
switched to gin - use logrus
This commit is contained in:
25
main.go
25
main.go
@@ -1,16 +1,39 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/mgerb/go-discord-bot/server/bot"
|
||||
"github.com/mgerb/go-discord-bot/server/bothandlers"
|
||||
"github.com/mgerb/go-discord-bot/server/config"
|
||||
"github.com/mgerb/go-discord-bot/server/webserver"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
func init() {
|
||||
//read config file
|
||||
config.Init()
|
||||
|
||||
// Log as JSON instead of the default ASCII formatter.
|
||||
log.SetFormatter(&log.JSONFormatter{})
|
||||
|
||||
// Output to stdout instead of the default stderr
|
||||
// Can be any io.Writer, see below for File example
|
||||
log.SetOutput(os.Stdout)
|
||||
|
||||
if config.Flags.Prod {
|
||||
// prod
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
// Only log the warning severity or above.
|
||||
log.SetLevel(log.WarnLevel)
|
||||
} else {
|
||||
// debug
|
||||
log.SetLevel(log.DebugLevel)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
//connect bot to account with token
|
||||
bot.Connect(config.Config.Token)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user