mirror of
https://github.com/replicatedhq/troubleshoot.git
synced 2026-02-14 10:19:54 +00:00
chore: fix noisy info logs (#1808)
* refine logging * keep progress message at level 0
This commit is contained in:
@@ -80,7 +80,7 @@ func HostAnalyze(
|
||||
|
||||
isExcluded, _ := analyzer.IsExcluded()
|
||||
if isExcluded {
|
||||
klog.Infof("excluding %q analyzer", analyzer.Title())
|
||||
klog.V(1).Infof("excluding %q analyzer", analyzer.Title())
|
||||
span.SetAttributes(attribute.Bool(constants.EXCLUDED, true))
|
||||
return nil
|
||||
}
|
||||
@@ -124,7 +124,7 @@ func Analyze(
|
||||
|
||||
analyzerInst := GetAnalyzer(analyzer)
|
||||
if analyzerInst == nil {
|
||||
klog.Info("Non-existent analyzer found in the spec. Please double-check the spelling and indentation of the analyzers in the spec.")
|
||||
klog.V(1).Info("Non-existent analyzer found in the spec. Please double-check the spelling and indentation of the analyzers in the spec.")
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ func Analyze(
|
||||
return nil, err
|
||||
}
|
||||
if isExcluded {
|
||||
klog.Infof("excluding %q analyzer", analyzerInst.Title())
|
||||
klog.V(1).Infof("excluding %q analyzer", analyzerInst.Title())
|
||||
span.SetAttributes(attribute.Bool(constants.EXCLUDED, true))
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ func findRookCephToolsPod(ctx context.Context, c *CollectCeph, namespace string)
|
||||
return &pods[0], nil
|
||||
}
|
||||
|
||||
klog.Info("rook ceph tools pod not found")
|
||||
klog.V(1).Info("rook ceph tools pod not found")
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ func (c *CollectEtcd) Collect(progressChan chan<- interface{}) (CollectorResult,
|
||||
fileName := generateFilenameFromCommand(command)
|
||||
stdout, stderr, err := debugInstance.executeCommand(command)
|
||||
if err != nil {
|
||||
klog.Infof("failed to exec command %s: %v", command, err)
|
||||
klog.V(2).Infof("failed to exec command %s: %v", command, err)
|
||||
continue
|
||||
}
|
||||
if len(stdout) > 0 {
|
||||
|
||||
@@ -213,7 +213,7 @@ func responseToOutput(response *http.Response, err error) ([]byte, error) {
|
||||
var rawJSON json.RawMessage
|
||||
if len(body) > 0 {
|
||||
if err := json.Unmarshal(body, &rawJSON); err != nil {
|
||||
klog.Infof("failed to unmarshal response body as JSON: %+v", err)
|
||||
klog.V(2).Infof("failed to unmarshal response body as JSON: %+v", err)
|
||||
rawJSON = json.RawMessage{}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -117,7 +117,7 @@ func imageExists(namespace string, clientConfig *rest.Config, registryCollector
|
||||
|
||||
remoteImage, err := imageRef.NewImage(context.Background(), &sysCtx)
|
||||
if err == nil {
|
||||
klog.Infof("image %s exists", image)
|
||||
klog.V(2).Infof("image %s exists", image)
|
||||
remoteImage.Close()
|
||||
return true, nil
|
||||
}
|
||||
|
||||
@@ -67,8 +67,17 @@ func InitKlog(verbosity int) {
|
||||
|
||||
// SetupLogger sets up klog logger based on viper configuration.
|
||||
func SetupLogger(v *viper.Viper) {
|
||||
quiet := v.GetBool("debug") || v.IsSet("v")
|
||||
SetQuiet(!quiet)
|
||||
shouldShowLogs := v.GetBool("debug") || v.IsSet("v")
|
||||
SetQuiet(!shouldShowLogs)
|
||||
|
||||
// If verbosity is set, configure klog verbosity level
|
||||
if v.IsSet("v") {
|
||||
verbosity := v.GetInt("v")
|
||||
if verbosity > 0 {
|
||||
// Use the existing InitKlog function to set verbosity
|
||||
InitKlog(verbosity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SetQuiet enables or disables klog logger.
|
||||
|
||||
@@ -243,7 +243,7 @@ func CollectWithContext(ctx context.Context, opts CollectOpts, p *troubleshootv1
|
||||
|
||||
isExcluded, _ := collector.IsExcluded()
|
||||
if isExcluded {
|
||||
klog.Infof("excluding %q collector", collector.Title())
|
||||
klog.V(1).Infof("excluding %q collector", collector.Title())
|
||||
span.SetAttributes(attribute.Bool(constants.EXCLUDED, true))
|
||||
span.End()
|
||||
continue
|
||||
|
||||
@@ -80,7 +80,7 @@ func ParseSupportBundle(doc []byte, followURI bool) (*troubleshootv1beta2.Suppor
|
||||
// use the upstream spec, otherwise fall back to
|
||||
// what's defined in the current spec
|
||||
if supportBundle.Spec.Uri != "" && followURI {
|
||||
klog.Infof("using upstream reference: %+v\n", supportBundle.Spec.Uri)
|
||||
klog.V(1).Infof("using upstream reference: %+v\n", supportBundle.Spec.Uri)
|
||||
upstreamSupportBundleContent, err := LoadSupportBundleSpec(supportBundle.Spec.Uri)
|
||||
if err != nil {
|
||||
klog.Errorf("failed to load upstream supportbundle, falling back")
|
||||
|
||||
Reference in New Issue
Block a user