1
0
mirror of https://github.com/mgerb/go-discord-bot synced 2026-01-10 09:02:49 +00:00

switched to gin - use logrus

This commit is contained in:
2018-02-06 18:54:13 +00:00
parent 74976de6cf
commit 5b6d74149d
12 changed files with 116 additions and 212 deletions

View File

@@ -3,9 +3,8 @@ package config
import (
"encoding/json"
"flag"
log "github.com/sirupsen/logrus"
"io/ioutil"
"log"
"os"
)
// Variables used for command line parameters
@@ -30,52 +29,45 @@ type configFile struct {
type configFlags struct {
Prod bool
TLS bool
}
// Init -
func Init() {
parseConfig()
parseFlags()
}
func parseConfig() {
log.Println("Reading config file...")
log.Debug("Reading config file...")
file, e := ioutil.ReadFile("./config.json")
if e != nil {
log.Printf("File error: %v\n", e)
os.Exit(1)
log.Fatal("File error: %v\n", e)
}
log.Printf("%s\n", string(file))
log.Debug("%s\n", string(file))
err := json.Unmarshal(file, &Config)
if err != nil {
log.Println(err)
log.Error(err)
}
}
func parseFlags() {
Flags.Prod = false
Flags.TLS = false
prod := flag.Bool("p", false, "Run in production")
tls := flag.Bool("tls", false, "Use TLS")
flag.Parse()
Flags.Prod = *prod
Flags.TLS = *tls
if *prod {
log.Println("Running in production mode")
if Flags.Prod {
log.Warn("Running in production mode")
}
}