summaryrefslogtreecommitdiff
path: root/crawler/init.go
diff options
context:
space:
mode:
authorhorus2018-02-20 17:44:58 +0100
committerhorus2018-02-20 17:44:58 +0100
commit0bc744ded5814273a9e1f3bf6fd09ffb252e4a87 (patch)
treeafcf6b7afa886a3234691ea695688b0c914aca48 /crawler/init.go
parentff9790d2e5c3482ccd6109adac475a9868fc0ab6 (diff)
downloadalkobote-0bc744ded5814273a9e1f3bf6fd09ffb252e4a87.tar.gz
Reintroduces debug as a config setting. (crawler)
Diffstat (limited to 'crawler/init.go')
-rw-r--r--crawler/init.go25
1 files changed, 16 insertions, 9 deletions
diff --git a/crawler/init.go b/crawler/init.go
index abf212b..a4fcb21 100644
--- a/crawler/init.go
+++ b/crawler/init.go
@@ -1,12 +1,10 @@
package main
import (
- "flag"
"strings"
log "github.com/Sirupsen/logrus"
- //"github.com/spf13/viper"
- //flag "github.com/spf13/pflag"
+ flag "github.com/spf13/pflag"
)
// global config, gets overwritten by main
@@ -14,21 +12,30 @@ var _conf Config
func init() {
// we need to parse the config because of log level setting
- configFile := flag.String("config", "", "path to config file")
- debug := flag.Bool("debug", false, "debug outputs")
- loglevel_f := flag.String("loglevel", "Warn", `sets log level, can be "Warn", "Info" or "Debug"`)
- loglevel := strings.ToLower(*loglevel_f)
+ configFile := flag.StringP("config", "c", "", "path to config file")
+ debug := flag.BoolP("debug", "d", false, "debug outputs")
+ verbose := flag.BoolP("verbose", "v", false, "same as --debug")
+ silent := flag.BoolP("silent", "s", false, "suppress outputs except warnings")
+ loglevel_f := flag.StringP("loglevel", "l", "Warn", `sets log level, can be "Warn", "Info" or "Debug"`)
flag.Parse()
+ loglevel := strings.ToLower(*loglevel_f)
- if *debug || loglevel == "debug" {
+ if *debug || *verbose || loglevel == "debug" {
log.SetLevel(log.DebugLevel)
- } else if loglevel == "Info" {
+ } else if loglevel == "info" {
log.SetLevel(log.InfoLevel)
} else {
log.SetLevel(log.WarnLevel)
}
+ if *silent {
+ log.SetLevel(log.WarnLevel)
+ }
+
_conf.parseConfig(*configFile)
+ if _conf.Debug && !*silent {
+ log.SetLevel(log.DebugLevel)
+ }
}