Add verbose flag for debug output control

Introduces log.Debug() function that respects a Verbose config flag, replacing direct [debug] fmt.Fprintf calls throughout the codebase. This allows debug logging to be toggled via -v/--verbose CLI flag.
This commit is contained in:
AI Bot
2026-04-19 11:06:52 +02:00
committed by Riyyi
parent 1dffd70db2
commit c90d2e8916
8 changed files with 90 additions and 70 deletions
+5 -5
View File
@@ -2,12 +2,12 @@ package aur
import (
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
"os"
"time"
"github.com/Riyyi/declpac/pkg/log"
)
var AURInfoURL = "https://aur.archlinux.org/rpc?v=5&type=info"
@@ -35,7 +35,7 @@ func New() *Client {
func (c *Client) Fetch(packages []string) (map[string]Package, error) {
start := time.Now()
fmt.Fprintf(os.Stderr, "[debug] aur.Fetch: starting...\n")
log.Debug("aur.Fetch: starting...")
result := make(map[string]Package)
@@ -51,7 +51,7 @@ func (c *Client) Fetch(packages []string) (map[string]Package, error) {
}
if len(uncached) == 0 {
fmt.Fprintf(os.Stderr, "[debug] aur.Fetch: done (cached) (%.2fs)\n", time.Since(start).Seconds())
log.Debug("aur.Fetch: done (cached) (%.2fs)", time.Since(start).Seconds())
for _, pkg := range packages {
result[pkg] = c.cache[pkg]
}
@@ -84,7 +84,7 @@ func (c *Client) Fetch(packages []string) (map[string]Package, error) {
result[r.Name] = r
}
fmt.Fprintf(os.Stderr, "[debug] aur.Fetch: done (%.2fs)\n", time.Since(start).Seconds())
log.Debug("aur.Fetch: done (%.2fs)", time.Since(start).Seconds())
return result, nil
}