diff options
author | Ratan Gupta <ratagupt@in.ibm.com> | 2017-11-22 15:44:42 +0530 |
---|---|---|
committer | Ratan Gupta <ratagupt@in.ibm.com> | 2018-03-15 00:20:22 +0530 |
commit | c27170ab2747f7854a06c4dc533c2ad3c88dd758 (patch) | |
tree | 11a39f5aac4bd26903746195541e18e96b74335c /ethernet_interface.cpp | |
parent | d475cd63286ec7b3f74c3959cabaa292b6648265 (diff) | |
download | phosphor-networkd-c27170ab2747f7854a06c4dc533c2ad3c88dd758.tar.gz phosphor-networkd-c27170ab2747f7854a06c4dc533c2ad3c88dd758.zip |
Reduce journal logs
Presently the code was creating the elog during reading of
the values from the config parser which creates
the journal log internally("Internal error Occured")
Apart from creating elog,Code also logs into the journal
more descriptive message saying which section and key
was not found.
The code which catches the exception that also logs
into the journal.
In the changed approach instead of throwing exception
we are returning the return code as not finding a section
or key in the network config file is not an error.
Change-Id: Ib89a3af6541fdf93fb5fa9a8e583d6c6ed88da79
Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
Diffstat (limited to 'ethernet_interface.cpp')
-rw-r--r-- | ethernet_interface.cpp | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/ethernet_interface.cpp b/ethernet_interface.cpp index 15f40fb..7d13c1c 100644 --- a/ethernet_interface.cpp +++ b/ethernet_interface.cpp @@ -398,14 +398,14 @@ ServerList EthernetInterface::getNameServerFromConf() systemd::config::networkFileSuffix; confPath /= fileName; ServerList servers; - try - { - config::Parser parser(confPath.string()); - servers = parser.getValues("Network", "DNS"); - } - catch (InternalFailure& e) + config::Parser parser(confPath.string()); + auto rc = config::ReturnCode::SUCCESS; + + std::tie(rc, servers) = parser.getValues("Network", "DNS"); + if (rc != config::ReturnCode::SUCCESS) { - log<level::INFO>("Exception getting DNS value from conf file"); + log<level::DEBUG>("Unable to get the value for network[DNS]", + entry("RC=%d", rc)); } return servers; } @@ -484,18 +484,20 @@ ServerList EthernetInterface::getNTPServersFromConf() fs::path confPath = manager.getConfDir(); std::string fileName = systemd::config::networkFilePrefix + interfaceName() + - systemd::config::networkFileSuffix; + systemd::config::networkFileSuffix; confPath /= fileName; + ServerList servers; - try - { - config::Parser parser(confPath.string()); - servers = parser.getValues("Network", "NTP"); - } - catch (InternalFailure& e) + config::Parser parser(confPath.string()); + auto rc = config::ReturnCode::SUCCESS; + + std::tie(rc, servers) = parser.getValues("Network", "NTP"); + if (rc != config::ReturnCode::SUCCESS) { - log<level::INFO>("Unable to find the NTP server configuration."); + log<level::DEBUG>("Unable to get the value for Network[NTP]", + entry("rc=%d", rc)); } + return servers; } |