Skip to content

Commit c855b9b

Browse files
committed
Enhance logging in GuessRepositoryTypesBatch for npm package results
- Added detailed logging for npm package detection results, including package name, version, and installation command. - Improved error handling logging for failed repository type guesses, ensuring clarity on the URL and error details. - Streamlined logging for cases with no npm package information.
1 parent a881e84 commit c855b9b

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

internal/experiments/guesser.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,36 @@ func (g *Guesser) GuessRepositoryTypesBatch(ctx context.Context, githubURLs []st
174174

175175
for batchResult := range resultChan {
176176
processedCount++
177+
url := githubURLs[batchResult.Index]
178+
177179
if batchResult.Error != nil {
178180
errorCount++
179181
g.logger.Debug("Failed to guess repository type",
180-
zap.String("url", githubURLs[batchResult.Index]),
182+
zap.String("url", url),
181183
zap.Error(batchResult.Error))
182184
// Keep empty result for failed URLs
183185
} else {
184186
results[batchResult.Index] = batchResult.Result
187+
188+
// Log individual result details
189+
if batchResult.Result != nil && batchResult.Result.NPM != nil {
190+
npmInfo := batchResult.Result.NPM
191+
if npmInfo.Exists {
192+
g.logger.Debug("Repository type guessing result: npm package found",
193+
zap.String("url", url),
194+
zap.String("package_name", npmInfo.PackageName),
195+
zap.String("version", npmInfo.Version),
196+
zap.String("install_cmd", npmInfo.InstallCmd))
197+
} else {
198+
g.logger.Debug("Repository type guessing result: npm package not found",
199+
zap.String("url", url),
200+
zap.String("package_name", npmInfo.PackageName),
201+
zap.String("error", npmInfo.Error))
202+
}
203+
} else {
204+
g.logger.Debug("Repository type guessing result: no npm package info",
205+
zap.String("url", url))
206+
}
185207
}
186208
}
187209

0 commit comments

Comments
 (0)