Пример #1
0
func LoadConfig() (cfg Config, err error) {
	var configfile string
	flag.StringVar(&configfile, "config",
		"/etc/goproxy/config.json", "config file")
	flag.Parse()

	file, err := os.Open(configfile)
	if err != nil {
		return
	}
	defer file.Close()

	dec := json.NewDecoder(file)
	err = dec.Decode(&cfg)
	if err != nil {
		return
	}

	lv, err := logging.GetLevelByName(cfg.Loglevel)
	if err != nil {
		return
	}

	err = logging.SetupDefault(cfg.Logfile, lv)
	if err != nil {
		return
	}

	logger, err = logging.NewFileLogger("default", -1, "goproxy")
	if err != nil {
		return
	}

	return
}
Пример #2
0
func init() {
	var logfile string
	var loglevel string

	flag.StringVar(&cipher, "cipher", "aes", "aes/des/tripledes/rc4")
	flag.StringVar(&keyfile, "keyfile", "key", "key and iv file")
	flag.StringVar(&username, "username", "", "username for connect")
	flag.StringVar(&password, "password", "", "password for connect")
	flag.StringVar(&blackfile, "black", "routes.list.gz", "blacklist file")

	flag.StringVar(&logfile, "logfile", "", "log file")
	flag.StringVar(&loglevel, "loglevel", "WARNING", "log level")
	flag.Parse()

	lv, err := logging.GetLevelByName(loglevel)
	if err != nil {
		panic(err.Error())
	}
	err = logging.SetupDefault(logfile, lv)
	if err != nil {
		panic(err.Error())
	}

	logger, err = logging.NewFileLogger("default", -1, "glookup")
	if err != nil {
		panic(err)
	}
}
Пример #3
0
func init() {
	logging.SetupDefault("", logging.LOG_INFO)
}