[TASK] add debugging

This commit is contained in:
Martin/Geno 2018-09-06 13:36:25 +02:00
parent 65047a6c8b
commit 73c4a38940
No known key found for this signature in database
GPG Key ID: 9D7D3C6BFF600C6A
3 changed files with 10 additions and 0 deletions

View File

@ -47,6 +47,9 @@ var serverCmd = &cobra.Command{
if config == nil || err != nil { if config == nil || err != nil {
log.Panicf("Could not load '%s' for configuration.", configPath) log.Panicf("Could not load '%s' for configuration.", configPath)
} }
if config.Debug {
log.SetLevel(log.DebugLevel)
}
db = database.ReadDBFile(config.DB) db = database.ReadDBFile(config.DB)
go func() { dbSaveWorker = file.NewSaveJSONWorker(time.Minute, config.DB, 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) log.Errorf("reload: could not load '%s' for new configuration. Skip reload.", configPath)
return return
} }
if config.Debug {
log.SetLevel(log.DebugLevel)
} else {
log.SetLevel(log.InfoLevel)
}
in.Close() in.Close()
in = allInput.Init(config.Input, logChannel) in = allInput.Init(config.Input, logChannel)
go in.Listen() go in.Listen()

View File

@ -3,6 +3,7 @@ package lib
// Struct of the configuration // Struct of the configuration
// e.g. under dev.sum7.eu/genofire/logmania/logmania_example.conf // e.g. under dev.sum7.eu/genofire/logmania/logmania_example.conf
type Config struct { type Config struct {
Debug bool `toml:"debug"`
DB string `toml:"database"` DB string `toml:"database"`
HTTPAddress string `toml:"http_address"` HTTPAddress string `toml:"http_address"`
Webroot string `toml:"webroot"` Webroot string `toml:"webroot"`

View File

@ -1,3 +1,4 @@
debug = false
database = "/tmp/logmania.state.json" database = "/tmp/logmania.state.json"
# have to be mote then a minute # have to be mote then a minute