Skip to content

Commit 27dc5a3

Browse files
removed extra prints on downloading runtimes
1 parent 1b285ea commit 27dc5a3

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

cmd/analyze.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ func genericRunTool(toolName string, workDirectory string, pathsToCheck []string
300300
runtime = config.Config.Runtimes()[tool.Runtime]
301301
isRuntimeInstalled = runtime == nil || config.Config.IsRuntimeInstalled(tool.Runtime, runtime)
302302
if !isRuntimeInstalled {
303-
fmt.Println("Runtime is not installed, installing...")
303+
fmt.Printf("%s runtime is not installed, installing...\n", tool.Runtime)
304304
err := config.InstallRuntime(tool.Runtime, runtime)
305305
if err != nil {
306306
return fmt.Errorf("failed to install %s runtime: %w", tool.Runtime, err)
@@ -312,7 +312,7 @@ func genericRunTool(toolName string, workDirectory string, pathsToCheck []string
312312
runtime = config.Config.Runtimes()[tool.Runtime]
313313
isRuntimeInstalled = runtime == nil || config.Config.IsRuntimeInstalled(tool.Runtime, runtime)
314314
if !isRuntimeInstalled {
315-
fmt.Println("Runtime is not installed, installing...")
315+
fmt.Printf("%s runtime is not installed, installing...\n", tool.Runtime)
316316
err := config.InstallRuntime(tool.Runtime, runtime)
317317
if err != nil {
318318
return fmt.Errorf("failed to install %s runtime: %w", tool.Runtime, err)

config/runtimes-installer.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,11 @@ func InstallRuntimes(config *ConfigType) error {
4848
// InstallRuntime installs a specific runtime
4949
func InstallRuntime(name string, runtimeInfo *plugins.RuntimeInfo) error {
5050
// Skip if already installed
51-
fmt.Printf("Checking if runtime %s v%s is installed\n", name, runtimeInfo.Version)
5251
if Config.IsRuntimeInstalled(name, runtimeInfo) {
5352
logger.Info("Runtime already installed", logrus.Fields{
5453
"runtime": name,
5554
"version": runtimeInfo.Version,
5655
})
57-
fmt.Printf("Runtime %s v%s is already installed\n", name, runtimeInfo.Version)
5856
return nil
5957
}
6058

utils/download.go

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,38 @@
11
package utils
22

33
import (
4+
"codacy/cli-v2/utils/logger"
45
"fmt"
56
"io"
6-
"log"
77
"net/http"
88
"os"
99
"path/filepath"
10+
11+
"github.com/sirupsen/logrus"
1012
)
1113

1214
func DownloadFile(url string, destDir string) (string, error) {
13-
log.Printf("Attempting to download from URL: %s", url)
15+
logger.Debug("Attempting to download from URL", logrus.Fields{
16+
"url": url,
17+
})
1418

1519
// Get the file name from the URL
1620
fileName := filepath.Base(url)
17-
log.Printf("Target filename: %s", fileName)
21+
logger.Debug("Target filename determined", logrus.Fields{
22+
"fileName": fileName,
23+
})
1824

1925
// Create the destination file path
2026
destPath := filepath.Join(destDir, fileName)
21-
log.Printf("Destination path: %s", destPath)
27+
logger.Debug("Destination path set", logrus.Fields{
28+
"destPath": destPath,
29+
})
2230

2331
_, errInfo := os.Stat(destPath)
2432
if errInfo != nil && os.IsExist(errInfo) {
25-
log.Printf("File already exists at destination, skipping download")
33+
logger.Debug("File already exists at destination, skipping download", logrus.Fields{
34+
"destPath": destPath,
35+
})
2636
return destPath, nil
2737
}
2838

@@ -34,7 +44,9 @@ func DownloadFile(url string, destDir string) (string, error) {
3444
defer outFile.Close()
3545

3646
// Make the HTTP GET request
37-
log.Printf("Making HTTP GET request...")
47+
logger.Debug("Making HTTP GET request", logrus.Fields{
48+
"url": url,
49+
})
3850
client := &http.Client{}
3951
req, err := http.NewRequest("GET", url, nil)
4052
if err != nil {
@@ -54,12 +66,14 @@ func DownloadFile(url string, destDir string) (string, error) {
5466
}
5567

5668
// Copy the response body to the destination file
57-
log.Printf("Downloading file content...")
69+
logger.Debug("Downloading file content")
5870
written, err := io.Copy(outFile, resp.Body)
5971
if err != nil {
6072
return "", fmt.Errorf("failed to copy file contents: %w", err)
6173
}
62-
log.Printf("Downloaded %d bytes", written)
74+
logger.Debug("Downloaded file successfully", logrus.Fields{
75+
"bytes": written,
76+
})
6377

6478
if written == 0 {
6579
return "", fmt.Errorf("downloaded file is empty (0 bytes)")

0 commit comments

Comments
 (0)