Example #1
0
func CheckConfig(cfg *Config, log *log4go.Logger) bool {
	var err error
	cfg.Re, err = regexp.Compile(cfg.Spider.TargetUrl)
	if err != nil {
		log.Error("TargetUrl not valid regrex!")
		return false
	}
	if cfg.Spider.CrawlInterval <= 0 {
		log.Error("CrawlInterval <= 0, should > 0!")
		return false
	}
	if cfg.Spider.CrawlTimeout <= 0 {
		log.Error("CrawlTimeout <= 0, should > 0!")
		return false
	}
	if cfg.Spider.MaxDepth <= 0 {
		log.Error("MaxDepth <= 0, should > 0!")
		return false
	}
	if cfg.Spider.ThreadCount <= 0 {
		log.Error("ThreadCount <= 0, should > 0!")
		return false
	}
	if len(cfg.Spider.OutputDirectory) == 0 {
		log.Error("OutputDirectory empty, should be not!")
		return false
	}
	if len(cfg.Spider.TargetUrl) == 0 {
		log.Error("TargetUrl empty, should be not!")
		return false
	}
	if len(cfg.Spider.UrlListFile) == 0 {
		log.Error("UrlListFile empty, should be not!")
		return false
	}
	return true
}
Example #2
0
func SetLog(extLog l4g.Logger) {
	extLog.Logf(l4g.TRACE, "SetLog(extLog=%v)", extLog)
	log = extLog
}