Beispiel #1
0
func InitLog(logdir string) {
	err := log.Init("mini_spider", "INFO", logdir, false, "M", 2)
	if err != nil {
		fmt.Println("Log init failed")
		os.Exit(-1)
	}
	log.Logger.Info("Open log done.")
}
func Test_CheckConfig_should_success_when_everythin_ok(t *testing.T) {
	var cfg Config
	cfg.Spider.UrlListFile = "test"
	cfg.Spider.TargetUrl = ".html"
	cfg.Spider.OutputDirectory = "output"
	cfg.Spider.CrawlInterval = 1
	cfg.Spider.CrawlTimeout = 10
	cfg.Spider.MaxDepth = 2
	cfg.Spider.ThreadCount = 8

	err := log.Init("mini_spider", "INFO", "test", false, "M", 2)
	if err != nil {
		t.Error("Log init failed")
	}

	err1 := CheckConfig(&cfg, &log.Logger)
	if !err1 {
		t.Error("CheckConfig failed")
	}
}