fix(logger): respect --debug for setting debug logger (#1955)

respect --debug parse
This commit is contained in:
Jo 2023-03-08 21:33:43 +00:00 committed by GitHub
parent 7e7764a797
commit f11f9058c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View file

@ -5,6 +5,7 @@ import (
"strings"
"github.com/Jguer/yay/v12/pkg/settings/parser"
"github.com/Jguer/yay/v12/pkg/text"
)
func (c *Configuration) ParseCommandLine(a *parser.Arguments) error {
@ -56,6 +57,10 @@ func (c *Configuration) handleOption(option, value string) bool {
c.CleanAfter = true
case "noafterclean", "nocleanafter":
c.CleanAfter = false
case "debug":
c.Debug = true
c.Runtime.Logger.Debug = true
text.GlobalLogger.Debug = true
case "devel":
c.Devel = true
case "nodevel":

View file

@ -314,7 +314,7 @@ func NewConfig(version string) (*Configuration, error) {
metadata.WithCacheFilePath(filepath.Join(newConfig.BuildDir, "aur.json")),
metadata.WithRequestEditorFn(userAgentFn),
metadata.WithBaseURL(newConfig.AURURL),
metadata.WithDebugLogger(newConfig.Runtime.Logger.Child("aur").Debugln),
metadata.WithDebugLogger(newConfig.Runtime.Logger.Debugln),
)
if errAURCache != nil {
return nil, fmt.Errorf(gotext.Get("failed to retrieve aur Cache")+": %w", errAURCache)
@ -324,7 +324,7 @@ func NewConfig(version string) (*Configuration, error) {
newConfig.Runtime.AURClient, errAUR = rpc.NewClient(
rpc.WithHTTPClient(newConfig.Runtime.HTTPClient),
rpc.WithRequestEditorFn(userAgentFn),
rpc.WithLogFn(newConfig.Runtime.Logger.Child("rpc").Debugln))
rpc.WithLogFn(newConfig.Runtime.Logger.Debugln))
if errAUR != nil {
return nil, errAUR
}