Commit d77fbec5 authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰

[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
parent e35fb004
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment