From a5141527ab5fd51c1776547ab806a7098f1cc952 Mon Sep 17 00:00:00 2001
From: jiangxinyu <jiangxinyu@kylinos.cn>
Date: Thu, 19 Sep 2024 13:37:57 +0800
Subject: [PATCH] Set verbosity after flag definition
Reference: https://github.com/google/cadvisor/pull/3384/commits/20317bfa449ae54cb2f9135482f08fb70a01c16f

---
 cmd/cadvisor.go | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/cmd/cadvisor.go b/cmd/cadvisor.go
index 505d091..b474512 100644
--- a/cmd/cadvisor.go
+++ b/cmd/cadvisor.go
@@ -141,13 +141,13 @@ func (ml *metricSetValue) Set(value string) error {
 func init() {
 	flag.Var(&ignoreMetrics, "disable_metrics", "comma-separated list of `metrics` to be disabled. Options are 'accelerator', 'cpu_topology','disk', 'diskIO', 'network', 'tcp', 'udp', 'percpu', 'sched', 'process', 'hugetlb', 'referenced_memory', 'resctrl'.")
 
-	// Default logging verbosity to V(2)
-	flag.Set("v", "2")
 }
 
 func main() {
 	klog.InitFlags(nil)
 	defer klog.Flush()
+	// Default logging verbosity to V(2)
+	_ = flag.Set("v", "2")
 	flag.Parse()
 
 	if *versionFlag {
-- 
2.46.0

