From 0a164783cab34521e8aa9cb478c901d2f7806564 Mon Sep 17 00:00:00 2001 From: Lyndsay Roger Date: Sat, 22 Aug 2015 08:16:44 +1200 Subject: [PATCH] Improe verbose output --- crawler.go | 9 ++++++--- seeder.go | 8 ++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/crawler.go b/crawler.go index 12f4314..98ad2b3 100644 --- a/crawler.go +++ b/crawler.go @@ -83,6 +83,7 @@ func crawlTwistee(tw *Twistee) { tw.status = statusCG tw.statusTime = time.Now() } + cs := tw.lastConnect tw.rating = 0 tw.connectFails = 0 tw.lastConnect = time.Now() @@ -100,14 +101,16 @@ func crawlTwistee(tw *Twistee) { } if config.verbose { - log.Printf("status - crawl done: twistee: %s newstatus: %v.%v received_addr: %v added_addr: %v CrawlTime: %s\n", + log.Printf("status - crawl done: twistee: %s s:r:f: %v:%v:%v addr: %v:%v CrawlTime: %s Last connect: %v ago\n", net.JoinHostPort(tw.na.IP.String(), strconv.Itoa(int(tw.na.Port))), tw.status, tw.rating, + tw.connectFails, len(ras), added, - time.Since(tw.crawlStart).String()) + time.Since(tw.crawlStart).String(), + time.Since(cs).String()) } // goroutine ends. deffered cleanup runs @@ -137,7 +140,7 @@ func crawlIP(tw *Twistee) ([]*wire.NetAddress, *CrawlError) { } defer conn.Close() - if config.verbose { + if config.debug { log.Printf("%s - Connected to remote address. Last connect was %v ago\n", ip, time.Since(tw.lastConnect).String()) } diff --git a/seeder.go b/seeder.go index 98f1990..2e1f4fb 100644 --- a/seeder.go +++ b/seeder.go @@ -157,14 +157,10 @@ func (s *Seeder) startCrawlers() { c.started++ } - if config.verbose || config.stats { - log.Printf("stats - started crawler: %s total: %v started: %v\n", c.desc, c.totalCount, c.started) - } + log.Printf("stats - started crawler: %s total: %v started: %v\n", c.desc, c.totalCount, c.started) } - if config.verbose || config.stats { - log.Printf("stats - completed starting crawlers. total twistees: %d\n", tcount) - } + log.Printf("stats - crawlers started. total twistees: %d\n", tcount) // returns and read lock released }