diff options
| author | Shulhan <ms@kilabit.info> | 2026-01-22 01:51:52 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2026-01-22 01:51:52 +0700 |
| commit | 2a4376d5ddeee82d4ef38f4953453abb43e85220 (patch) | |
| tree | fd28f274ba9d0f06a69e4bc054b0443f7f4500d8 /brokenlinks | |
| parent | 79eaccc81b85eb92dab9cf18d52662f367903652 (diff) | |
| download | jarink-2a4376d5ddeee82d4ef38f4953453abb43e85220.tar.xz | |
brokenlinks: print the progress to stderr
Each time the scan start, new queue add, fetching start, print the
message to stderr.
This remove the verbose options for better user experience.
Diffstat (limited to 'brokenlinks')
| -rw-r--r-- | brokenlinks/brokenlinks_test.go | 7 | ||||
| -rw-r--r-- | brokenlinks/options.go | 2 | ||||
| -rw-r--r-- | brokenlinks/worker.go | 10 |
3 files changed, 6 insertions, 13 deletions
diff --git a/brokenlinks/brokenlinks_test.go b/brokenlinks/brokenlinks_test.go index a04be7f..eedad33 100644 --- a/brokenlinks/brokenlinks_test.go +++ b/brokenlinks/brokenlinks_test.go @@ -275,7 +275,6 @@ func TestScan(t *testing.T) { Url: testUrl, IgnoreStatus: `403`, Insecure: true, - IsVerbose: true, }, exp: map[string][]jarink.Link{ testUrl: []jarink.Link{ @@ -362,8 +361,7 @@ func TestScan(t *testing.T) { // pages other than below of "/page2" itself. desc: `With Url=/page2`, opts: brokenlinks.Options{ - Url: testUrl + `/page2`, - IsVerbose: true, + Url: testUrl + `/page2`, }, exp: map[string][]jarink.Link{ testUrl + `/page2`: []jarink.Link{ @@ -497,8 +495,7 @@ func TestScan_slow(t *testing.T) { } var opts = brokenlinks.Options{ - Url: testUrl, - IsVerbose: true, + Url: testUrl, } gotResult, err := brokenlinks.Scan(opts) if err != nil { diff --git a/brokenlinks/options.go b/brokenlinks/options.go index 2703f8d..e5f9fcf 100644 --- a/brokenlinks/options.go +++ b/brokenlinks/options.go @@ -27,8 +27,6 @@ type Options struct { IgnoreStatus string ignoreStatus []int - IsVerbose bool - // Insecure do not report error on server with invalid certificates. Insecure bool } diff --git a/brokenlinks/worker.go b/brokenlinks/worker.go index 07bda88..a286362 100644 --- a/brokenlinks/worker.go +++ b/brokenlinks/worker.go @@ -139,6 +139,7 @@ func (wrk *worker) scanAll() (result *Result, err error) { for x < len(wrk.queue) { linkq = wrk.queue[x] x++ + wrk.log.Printf(`scan %d/%d: %s`, x, len(wrk.queue), linkq.Url) resultq = wrk.scan(linkq) wrk.processResult(resultq) } @@ -202,6 +203,7 @@ func (wrk *worker) processResult(resultq map[string]jarink.Link) { continue } wrk.queue = append(wrk.queue, linkq) + wrk.log.Printf(`queue %d: %s`, len(wrk.queue), linkq.Url) } } @@ -327,14 +329,10 @@ func (wrk *worker) fetch(linkq jarink.Link) (httpResp *http.Response, err error) var retry int for retry < 5 { if linkq.Kind == int(atom.Img) { - if wrk.opts.IsVerbose { - wrk.log.Printf("fetch: HEAD %s", linkq.Url) - } + wrk.log.Printf("fetch: HEAD %s", linkq.Url) httpResp, err = wrk.httpc.Head(linkq.Url) } else { - if wrk.opts.IsVerbose { - wrk.log.Printf("fetch: GET %s", linkq.Url) - } + wrk.log.Printf("fetch: GET %s", linkq.Url) httpResp, err = wrk.httpc.Get(linkq.Url) } if err == nil { |
