- gofmt main.go to fix tab indentation in main() body - stats.go ComputeSummary: return nil when Answers and ByType are empty - dns/types.go: remove duplicate ParseQueryType (dead code) - formatter.go: log hook errors to stderr when Debug > 0; add Debug to Config - text.go referralID: remove redundant depth==0 branch - text.go writeServers: remove version lookup placeholder string Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
co-authored by
Copilot
multica-agent
parent
5a54834c5f
commit
8e7beacc22
@@ -1,6 +1,7 @@
|
||||
package output
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
@@ -28,6 +29,7 @@ type Config struct {
|
||||
Verbose bool
|
||||
Quiet bool
|
||||
Color bool
|
||||
Debug int
|
||||
}
|
||||
|
||||
func DefaultConfig() *Config {
|
||||
@@ -69,16 +71,21 @@ func AttachHooks(cfg *Config, formatter Formatter) *traverse.TraverserHooks {
|
||||
if cfg == nil || formatter == nil {
|
||||
return nil
|
||||
}
|
||||
logErr := func(context string, err error) {
|
||||
if err != nil && cfg.Debug > 0 {
|
||||
fmt.Fprintf(os.Stderr, "Debug: formatter %s: %v\n", context, err)
|
||||
}
|
||||
}
|
||||
return &traverse.TraverserHooks{
|
||||
OnEvent: func(event traverse.TraversalEvent) {
|
||||
switch {
|
||||
case event.IsResolve && cfg.ShowResolves:
|
||||
_ = formatter.WriteResolve(event)
|
||||
logErr("WriteResolve", formatter.WriteResolve(event))
|
||||
case !event.IsResolve && cfg.ShowProgress:
|
||||
_ = formatter.WriteProgress(event)
|
||||
logErr("WriteProgress", formatter.WriteProgress(event))
|
||||
}
|
||||
if event.Stage == traverse.EventComplete && cfg.ShowAllStats {
|
||||
_ = formatter.WriteResult(event.Result)
|
||||
logErr("WriteResult", formatter.WriteResult(event.Result))
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user