diff options
| -rw-r--r-- | llog/llog.go | 10 | ||||
| -rw-r--r-- | main.go | 3 |
2 files changed, 13 insertions, 0 deletions
diff --git a/llog/llog.go b/llog/llog.go index 52ffc40..3c05012 100644 --- a/llog/llog.go +++ b/llog/llog.go @@ -18,6 +18,16 @@ const ( var Level LogLevel = l_DDebug +func SetLogLevelFromString(level string) { + for i, l := range getLevelNames() { + if l == level { + Level = LogLevel(i) + return + } + } + Error(fmt.Sprintf("Invalid log level: %s", level)) +} + func getLevelNames() []string { return []string{"Fatal", "Error", "Warning", "Info", "Debug", "DDebug"} } @@ -214,11 +214,14 @@ func setupRoutes() { func main() { config := Config{} + logLevel := flag.String("loglevel", "Warning", "log level") flag.IntVar(&config.port, "port", 8080, "port to listen to") flag.StringVar(&config.backends, "backends", "dummy youtube spotify", "music backend to use") flag.StringVar(&config.localMusicDir, "serve-music-dir", "", "local music directory to serve") flag.Parse() + llog.SetLogLevelFromString(*logLevel) + wrms = NewWrms(config) defer wrms.Close() |
