summaryrefslogtreecommitdiff
path: root/crawler/init.go
blob: abf212bbd9492e9870970d5f10dfaf466f0ce645 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package main

import (
	"flag"
	"strings"

	log "github.com/Sirupsen/logrus"
	//"github.com/spf13/viper"
	//flag "github.com/spf13/pflag"
)

// global config, gets overwritten by main
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)

	flag.Parse()

	if *debug || loglevel == "debug" {
		log.SetLevel(log.DebugLevel)
	} else if loglevel == "Info" {
		log.SetLevel(log.InfoLevel)
	} else {
		log.SetLevel(log.WarnLevel)
	}

	_conf.parseConfig(*configFile)

}