Skip to content

Commit

Permalink
helpful logging
Browse files Browse the repository at this point in the history
  • Loading branch information
dustin-decker committed Feb 16, 2022
1 parent 1e7ee2f commit e15fa3a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func Start(ctx context.Context, options ...EngineOption) *Engine {
logrus.Warn("No concurrency specified, defaulting to ", numCPU)
e.concurrency = numCPU
}
logrus.Debugf("running with up to %d workers", e.concurrency)

var workerWg sync.WaitGroup
for i := 0; i < e.concurrency; i++ {
Expand Down
8 changes: 7 additions & 1 deletion pkg/sources/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/go-errors/errors"
gogit "github.com/go-git/go-git/v5"
"github.com/google/go-github/v41/github"
"github.com/sirupsen/logrus"
log "github.com/sirupsen/logrus"
"golang.org/x/oauth2"
"golang.org/x/sync/semaphore"
Expand Down Expand Up @@ -300,6 +301,8 @@ func (s *Source) Chunks(ctx context.Context, chunksChan chan *sources.Chunk) err
rand.Shuffle(len(s.repos), func(i, j int) { s.repos[i], s.repos[j] = s.repos[j], s.repos[i] })
}

scanned := 0

log.Debugf("Found %v total repos to scan", len(s.repos))
wg := sync.WaitGroup{}
errChan := make(chan error)
Expand All @@ -309,6 +312,7 @@ func (s *Source) Chunks(ctx context.Context, chunksChan chan *sources.Chunk) err
go func(ctx context.Context, errCh chan error, repoURL string, i int) {
defer s.jobSem.Release(1)
defer wg.Done()

s.SetProgressComplete(i, len(s.repos), fmt.Sprintf("Repo: %s", repoURL))

if !strings.HasSuffix(repoURL, ".git") {
Expand All @@ -317,7 +321,7 @@ func (s *Source) Chunks(ctx context.Context, chunksChan chan *sources.Chunk) err
if strings.Contains(repoURL, "DefinitelyTyped") {
return
}
s.log.WithField("repo", repoURL).Debug("attempting to clone repo")
s.log.WithField("repo", repoURL).Debugf("attempting to clone repo %d/%d", i+1, len(s.repos))
var path string
var repo *gogit.Repository
var err error
Expand All @@ -344,6 +348,8 @@ func (s *Source) Chunks(ctx context.Context, chunksChan chan *sources.Chunk) err
if err != nil {
log.WithError(err).Errorf("unable to scan repo, continuing")
}
scanned += 1
logrus.Debugf("scanned %d/%d repos", scanned, len(s.repos))
}(ctx, errChan, repoURL, i)
}

Expand Down

0 comments on commit e15fa3a

Please sign in to comment.