diff --git a/agent/help_flag_test.go b/agent/help_flag_test.go index 3ca67e205..1b4acbe87 100644 --- a/agent/help_flag_test.go +++ b/agent/help_flag_test.go @@ -24,7 +24,18 @@ var _ = Describe("Help flag for host agent", func() { "-namespace string", "-skip-installation", "-version", - "-log-level int", + "-add_dir_header", + "-alsologtostderr", + "-log_backtrace_at value", + "-log_dir string", + "-log_file string", + "-log_file_max_size uint", + "-logtostderr", + "-skip_headers", + "-skip_log_headers", + "-stderrthreshold value", + "-v value", + "-vmodule value", } ) diff --git a/agent/main.go b/agent/main.go index f85cea4b6..38a8d7793 100644 --- a/agent/main.go +++ b/agent/main.go @@ -72,6 +72,16 @@ func (l *labelFlags) Set(value string) error { } } +func isFlagPassed(name string) bool { + found := false + flag.Visit(func(f *flag.Flag) { + if f.Name == name { + found = true + } + }) + return found +} + var ( namespace string scheme *runtime.Scheme @@ -80,7 +90,6 @@ var ( downloadpath string skipInstallation bool printVersion bool - logLevel int ) // TODO - fix logging @@ -93,7 +102,6 @@ func main() { flag.StringVar(&downloadpath, "downloadpath", "/var/lib/byoh/bundles", "File System path to keep the downloads") flag.BoolVar(&skipInstallation, "skip-installation", false, "If you want to skip installation of the kubernetes component binaries") flag.BoolVar(&printVersion, "version", false, "Print the version of the agent") - flag.IntVar(&logLevel, "log-level", 0, "Determines the verbosity of the system logs (Default: 0)") flag.Parse() if printVersion { @@ -106,7 +114,14 @@ func main() { _ = corev1.AddToScheme(scheme) _ = clusterv1.AddToScheme(scheme) - logger := klogr.New().V(logLevel) + // checking if log level flag has been explicitly set + // else setting the flag at 1 + if !isFlagPassed("v") { + flag.Set("v", "1") + } + + // setting info log verbosity level at 1 + logger := klogr.New().V(1) ctrl.SetLogger(logger) config, err := ctrl.GetConfig() if err != nil {