distributor: make loglevel configurable

This commit is contained in:
Geno 2021-09-15 18:54:23 +02:00
parent caf4ccb205
commit 889563b8b2
1 changed files with 5 additions and 0 deletions

View File

@ -7,6 +7,7 @@ import (
"dev.sum7.eu/genofire/golang-lib/file" "dev.sum7.eu/genofire/golang-lib/file"
"github.com/bdlm/log" "github.com/bdlm/log"
"github.com/bdlm/std/logger"
"unifiedpush.org/go/np2p_dbus/distributor" "unifiedpush.org/go/np2p_dbus/distributor"
"unifiedpush.org/go/np2p_dbus/storage" "unifiedpush.org/go/np2p_dbus/storage"
) )
@ -37,9 +38,13 @@ func defaultPath(given, filename string) string {
func main() { func main() {
configPath := "" configPath := ""
loglevel := 40
flag.StringVar(&configPath, "c", configPath, "path to configuration file") flag.StringVar(&configPath, "c", configPath, "path to configuration file")
flag.IntVar(&loglevel, "l", loglevel, "loglevel")
flag.Parse() flag.Parse()
log.SetLevel(logger.Level(loglevel))
config := &configData{} config := &configData{}
configPath = defaultPath(configPath, "config.toml") configPath = defaultPath(configPath, "config.toml")
if err := file.ReadTOML(configPath, config); err != nil { if err := file.ReadTOML(configPath, config); err != nil {