From: Tomek Mrugalski Date: Thu, 8 Feb 2018 04:49:18 +0000 (+0000) Subject: [github41] Initialize logging before reading configuration X-Git-Tag: trac5524_base~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d77fbec5a003a69cab207aa741133015f2657878;p=thirdparty%2Fkea.git [github41] Initialize logging before reading configuration More precisely, before reading the "Dhcp4" and "Dhcp6" configurations to log errors thrown because of any configuration loading issues. # Conflicts: # src/bin/dhcp4/kea_controller.cc # src/bin/dhcp6/kea_controller.cc --- diff --git a/src/bin/dhcp4/ctrl_dhcp4_srv.cc b/src/bin/dhcp4/ctrl_dhcp4_srv.cc index 6a82e07be5..c30e6e843d 100644 --- a/src/bin/dhcp4/ctrl_dhcp4_srv.cc +++ b/src/bin/dhcp4/ctrl_dhcp4_srv.cc @@ -319,6 +319,10 @@ ControlledDhcpv4Srv::commandConfigSetHandler(const string&, Daemon::configureLogger(args->get("Logging"), CfgMgr::instance().getStagingCfg()); + // Let's apply the new logging. We do it early, so we'll be able to print + // out what exactly is wrong with the new socnfig in case of problems. + CfgMgr::instance().getStagingCfg()->applyLoggingCfg(); + // Now we configure the server proper. ConstElementPtr result = processConfig(dhcp4); @@ -332,6 +336,11 @@ ControlledDhcpv4Srv::commandConfigSetHandler(const string&, // Use new configuration. CfgMgr::instance().commit(); + } else { + // Ok, we applied the logging from the upcoming configuration, but + // there were problems with the config. As such, we need to back off + // and revert to the previous logging configuration. + CfgMgr::instance().getCurrentCfg()->applyLoggingCfg(); } return (result); diff --git a/src/bin/dhcp6/ctrl_dhcp6_srv.cc b/src/bin/dhcp6/ctrl_dhcp6_srv.cc index dceb6367fb..4f333243fb 100644 --- a/src/bin/dhcp6/ctrl_dhcp6_srv.cc +++ b/src/bin/dhcp6/ctrl_dhcp6_srv.cc @@ -322,6 +322,10 @@ ControlledDhcpv6Srv::commandConfigSetHandler(const string&, Daemon::configureLogger(args->get("Logging"), CfgMgr::instance().getStagingCfg()); + // Let's apply the new logging. We do it early, so we'll be able to print + // out what exactly is wrong with the new socnfig in case of problems. + CfgMgr::instance().getStagingCfg()->applyLoggingCfg(); + // Now we configure the server proper. ConstElementPtr result = processConfig(dhcp6); @@ -335,6 +339,11 @@ ControlledDhcpv6Srv::commandConfigSetHandler(const string&, // Use new configuration. CfgMgr::instance().commit(); + } else { + // Ok, we applied the logging from the upcoming configuration, but + // there were problems with the config. As such, we need to back off + // and revert to the previous logging configuration. + CfgMgr::instance().getCurrentCfg()->applyLoggingCfg(); } return (result);