flag for journallog

This commit is contained in:
2021-10-05 19:12:20 +02:00
parent 831ced97af
commit 618a23627d
3 changed files with 20 additions and 10 deletions

25
main.go
View File

@@ -15,6 +15,7 @@ import (
"github.com/gorilla/mux"
_ "github.com/mattn/go-sqlite3"
log "github.com/sirupsen/logrus"
"github.com/wercker/journalhook"
"go.uber.org/ratelimit"
"gopkg.in/yaml.v3"
"net"
@@ -28,16 +29,17 @@ import (
)
var (
conf = utils.Conf{}
demoLoader = &csgo.DemoMatchLoader{}
router *mux.Router
db *utils.DBWithLock
sendGC chan *csgo.Demo
demoParser = &csgo.DemoParser{}
firstHK = true
rL ratelimit.Limiter
configFlag = flag.String("config", "config.yaml", "Set config to use")
authCodeFlag = flag.String("authcode", "", "Provide Steam AuthCode to login")
conf = utils.Conf{}
demoLoader = &csgo.DemoMatchLoader{}
router *mux.Router
db *utils.DBWithLock
sendGC chan *csgo.Demo
demoParser = &csgo.DemoParser{}
firstHK = true
rL ratelimit.Limiter
configFlag = flag.String("config", "config.yaml", "Set config to use")
authCodeFlag = flag.String("authcode", "", "Provide Steam AuthCode to login")
journalLogFlag = flag.Bool("journal", false, "Log to systemd journal instead of stdout")
)
type PlayerResponse struct {
@@ -371,6 +373,9 @@ func main() {
lvl, err := log.ParseLevel(conf.Logging.Level)
utils.Check(err)
log.SetLevel(lvl)
if *journalLogFlag {
journalhook.Enable()
}
db = &utils.DBWithLock{
Lock: new(sync.RWMutex),