From 73c4a389409e529d3bd53fd7733edbe335ca4540 Mon Sep 17 00:00:00 2001 From: Martin/Geno Date: Thu, 6 Sep 2018 13:36:25 +0200 Subject: [PATCH] [TASK] add debugging --- cmd/server.go | 8 ++++++++ lib/config.go | 1 + logmania_example.conf | 1 + 3 files changed, 10 insertions(+) diff --git a/cmd/server.go b/cmd/server.go index be134ed..7cafaa7 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -47,6 +47,9 @@ var serverCmd = &cobra.Command{ if config == nil || err != nil { log.Panicf("Could not load '%s' for configuration.", configPath) } + if config.Debug { + log.SetLevel(log.DebugLevel) + } db = database.ReadDBFile(config.DB) go func() { dbSaveWorker = file.NewSaveJSONWorker(time.Minute, config.DB, db) }() @@ -124,6 +127,11 @@ func reload() { log.Errorf("reload: could not load '%s' for new configuration. Skip reload.", configPath) return } + if config.Debug { + log.SetLevel(log.DebugLevel) + } else { + log.SetLevel(log.InfoLevel) + } in.Close() in = allInput.Init(config.Input, logChannel) go in.Listen() diff --git a/lib/config.go b/lib/config.go index fca33f9..b461c3d 100644 --- a/lib/config.go +++ b/lib/config.go @@ -3,6 +3,7 @@ package lib // Struct of the configuration // e.g. under dev.sum7.eu/genofire/logmania/logmania_example.conf type Config struct { + Debug bool `toml:"debug"` DB string `toml:"database"` HTTPAddress string `toml:"http_address"` Webroot string `toml:"webroot"` diff --git a/logmania_example.conf b/logmania_example.conf index 62db18f..ca628fe 100644 --- a/logmania_example.conf +++ b/logmania_example.conf @@ -1,3 +1,4 @@ +debug = false database = "/tmp/logmania.state.json" # have to be mote then a minute