diff --git a/pkg/db/executor.go b/pkg/db/executor.go index 4d48c0730..8fa06b5d1 100644 --- a/pkg/db/executor.go +++ b/pkg/db/executor.go @@ -4,6 +4,8 @@ import ( "time" alpm "github.com/Jguer/go-alpm/v2" + + "github.com/Jguer/yay/v12/pkg/text" ) type ( @@ -59,4 +61,6 @@ type Executor interface { SyncPackages(...string) []IPackage SyncSatisfier(string) IPackage SyncSatisfierExists(string) bool + + SetLogger(logger *text.Logger) } diff --git a/pkg/db/ialpm/high_level.go b/pkg/db/ialpm/high_level.go index 5694ce0c1..56a53bd02 100644 --- a/pkg/db/ialpm/high_level.go +++ b/pkg/db/ialpm/high_level.go @@ -2,6 +2,8 @@ package ialpm import ( alpm "github.com/Jguer/go-alpm/v2" + + "github.com/Jguer/yay/v12/pkg/text" ) // GetPackageNamesBySource returns package names with and without correspondence in SyncDBS respectively. @@ -43,3 +45,7 @@ func (ae *AlpmExecutor) InstalledSyncPackageNames() []string { return ae.installedSyncPkgNames } + +func (ae *AlpmExecutor) SetLogger(logger *text.Logger) { + ae.log = logger +} diff --git a/pkg/upgrade/sources.go b/pkg/upgrade/sources.go index 19dfd5122..c065a98ed 100644 --- a/pkg/upgrade/sources.go +++ b/pkg/upgrade/sources.go @@ -27,7 +27,7 @@ func UpDevel( for pkgName, pkg := range remote { if localCache.ToUpgrade(ctxTimeout, pkgName) { if _, ok := aurdata[pkgName]; !ok { - text.Warnln(gotext.Get("ignoring package devel upgrade (no AUR info found):"), pkgName) + log.Warnln(gotext.Get("ignoring package devel upgrade (no AUR info found):"), pkgName) continue } @@ -53,11 +53,12 @@ func UpDevel( return toUpgrade } -func printIgnoringPackage(logger *text.Logger, pkg db.IPackage, newPkgVersion string) { +func printIgnoringPackage(log *text.Logger, pkg db.IPackage, newPkgVersion string) { left, right := GetVersionDiff(pkg.Version(), newPkgVersion) - logger.Warnln(gotext.Get("%s: ignoring package upgrade (%s => %s)", - text.Cyan(pkg.Name()), + pkgName := pkg.Name() + log.Warnln(gotext.Get("%s: ignoring package upgrade (%s => %s)", + text.Cyan(pkgName), left, right, )) } diff --git a/print.go b/print.go index b807e0f8a..3426e0b9d 100644 --- a/print.go +++ b/print.go @@ -103,10 +103,9 @@ func printUpdateList(ctx context.Context, cfg *settings.Configuration, cmdArgs * dbExecutor db.Executor, enableDowngrade bool, filter upgrade.Filter, ) error { quietMode := cmdArgs.ExistsArg("q", "quiet") - logger := cfg.Runtime.Logger.Child("update-list") - if quietMode { // TODO: handle quiet mode in a better way - logger = text.NewLogger(io.Discard, os.Stdin, cfg.Debug, "update-list") - } + // TODO: handle quiet mode in a better way + logger := text.NewLogger(io.Discard, os.Stdin, cfg.Debug, "update-list") + dbExecutor.SetLogger(logger.Child("db")) targets := mapset.NewThreadUnsafeSet(cmdArgs.Targets...) grapher := dep.NewGrapher(dbExecutor, cfg.Runtime.AURCache, false, settings.NoConfirm, @@ -141,8 +140,8 @@ func printUpdateList(ctx context.Context, cfg *settings.Configuration, cmdArgs * if quietMode { fmt.Printf("%s\n", pkgName) } else { - fmt.Printf("%s %s -> %s\n", text.Bold(pkgName), text.Green(ii.LocalVersion), - text.Green(ii.Version)) + fmt.Printf("%s %s -> %s\n", text.Bold(pkgName), text.Bold(text.Green(ii.LocalVersion)), + text.Bold(text.Green(ii.Version))) } targets.Remove(pkgName)