diff --git a/src/vnsw/agent/contrail-vrouter-agent.conf b/src/vnsw/agent/contrail-vrouter-agent.conf index 03a3b8b76b0..b6bb216e92a 100644 --- a/src/vnsw/agent/contrail-vrouter-agent.conf +++ b/src/vnsw/agent/contrail-vrouter-agent.conf @@ -20,7 +20,7 @@ # agent_mode= # Enable/disable debug logging. Possible values are 0 (disable) and 1 (enable) -# debug=0 +debug=0 # Aging time for flow-records in seconds # flow_cache_timeout=0 diff --git a/src/vnsw/agent/init/agent_param.cc b/src/vnsw/agent/init/agent_param.cc index ea9a951bec6..db51703d5a7 100644 --- a/src/vnsw/agent/init/agent_param.cc +++ b/src/vnsw/agent/init/agent_param.cc @@ -427,13 +427,7 @@ void AgentParam::ParseDefaultSection() { log_local_ = false; } - if (optional debug_opt = - tree_.get_optional("DEFAULT.debug")) { - debug_ = true; - } else { - debug_ = false; - } - + GetValueFromTree(debug_, "DEFAULT.debug"); GetValueFromTree(use_syslog_, "DEFAULT.use_syslog"); if (!GetValueFromTree(syslog_facility_, "DEFAULT.syslog_facility")) { syslog_facility_ = "LOG_LOCAL0"; @@ -717,15 +711,13 @@ void AgentParam::ParseDefaultSectionArguments GetValueFromTree(log_file_size_, "DEFAULT.log_file_size"); GetOptValue(var_map, log_level_, "DEFAULT.log_level"); GetOptValue(var_map, syslog_facility_, "DEFAULT.syslog_facility"); + GetOptValue(var_map, debug_, "DEFAULT.debug"); if (var_map.count("DEFAULT.use_syslog")) { use_syslog_ = true; } if (var_map.count("DEFAULT.log_local")) { log_local_ = true; } - if (var_map.count("DEFAULT.debug")) { - debug_ = true; - } if (var_map.count("DEFAULT.log_flow")) { log_flow_ = true; } @@ -1277,7 +1269,7 @@ AgentParam::AgentParam(bool enable_flow_options, ("DEFAULT.collectors", opt::value >()->multitoken(), "Collector server list") - ("DEFAULT.debug", "Enable debug logging") + ("DEFAULT.debug", opt::value(), "Enable / Disable debug logging") ("DEFAULT.flow_cache_timeout", opt::value()->default_value(Agent::kDefaultFlowCacheTimeout), "Flow aging time in seconds") diff --git a/src/vnsw/agent/init/test/cfg-default1.ini b/src/vnsw/agent/init/test/cfg-default1.ini index d4aae55047c..aa56b87fce4 100644 --- a/src/vnsw/agent/init/test/cfg-default1.ini +++ b/src/vnsw/agent/init/test/cfg-default1.ini @@ -16,7 +16,7 @@ server=127.0.0.1 agent_mode=tsn # Enable/disable debug logging. Possible values are 0 (disable) and 1 (enable) -debug=1 +debug=0 # Aging time for flow-records in seconds flow_cache_timeout=60 diff --git a/src/vnsw/agent/init/test/test_agent_init.cc b/src/vnsw/agent/init/test/test_agent_init.cc index a18f817e17b..5487ea91277 100644 --- a/src/vnsw/agent/init/test/test_agent_init.cc +++ b/src/vnsw/agent/init/test/test_agent_init.cc @@ -63,6 +63,7 @@ TEST_F(FlowTest, Agent_Conf_file_1) { EXPECT_EQ(param.agent_mode(), AgentParam::VROUTER_AGENT); EXPECT_STREQ(param.agent_base_dir().c_str(), "/var/lib/contrail"); EXPECT_EQ(param.subnet_hosts_resolvable(), true); + EXPECT_TRUE(param.debug()); } TEST_F(FlowTest, Agent_Conf_file_2) { @@ -311,6 +312,7 @@ TEST_F(FlowTest, Default_Cmdline_arg1) { EXPECT_STREQ(param.log_level().c_str(), "SYS_ERR"); EXPECT_TRUE(param.isXenMode()); EXPECT_EQ(param.agent_mode(), AgentParam::TSN_AGENT); + EXPECT_FALSE(param.debug()); } /* Some command line args have default values. If user has not passed these