Commit 59e1089f authored by Shawn Routhier's avatar Shawn Routhier

[trac3667] Updates per review

Move lease_stats.h to leae_file_stats.h

Move logging init code into its own function.
parent 05465de6
XXX. [func] sar
A class, LeaseFileStats, has been added to provide simple
statistics for use with lease files. Also added logging
to the kea-lfc process per the design.
See http://kea.isc.org/wiki/LFCDesign for the design.
(Trac #3667, git )
887. [func] sar
A new process, kea-lfc, has been added. It is meant to
be periodically executed by the DHCPv4 and DHCPv6 servers
......
......@@ -77,37 +77,9 @@ LFCController::launch(int argc, char* argv[], const bool test_mode) {
usage(ex.what());
throw; // rethrow it
}
// If we are running in test mode use the environment variables
// else use our defaults
if (test_mode) {
initLogger();
}
else {
OutputOption option;
LoggerManager manager;
initLogger(lfc_app_name_, INFO, 0, NULL, false);
// Prepare the objects to define the logging specification
LoggerSpecification spec(getRootLoggerName(),
keaLoggerSeverity(INFO),
keaLoggerDbglevel(0));
// If we are running in verbose (debugging) mode
// we send the output to the console, otherwise
// by default we send it to the SYSLOG
if (verbose_) {
option.destination = OutputOption::DEST_CONSOLE;
} else {
option.destination = OutputOption::DEST_SYSLOG;
}
// ... and set the destination
spec.addOutputOption(option);
manager.process(spec);
}
// Start up the logging system.
startLogger(test_mode);
LOG_INFO(lfc_logger, LFC_START);
......@@ -419,5 +391,40 @@ LFCController::fileRotate() const {
<< ") error: " << strerror(errno));
}
}
void
LFCController::startLogger(const bool test_mode) const {
// If we are running in test mode use the environment variables
// else use our defaults
if (test_mode) {
initLogger();
}
else {
OutputOption option;
LoggerManager manager;
initLogger(lfc_app_name_, INFO, 0, NULL, false);
// Prepare the objects to define the logging specification
LoggerSpecification spec(getRootLoggerName(),
keaLoggerSeverity(INFO),
keaLoggerDbglevel(0));
// If we are running in verbose (debugging) mode
// we send the output to the console, otherwise
// by default we send it to the SYSLOG
if (verbose_) {
option.destination = OutputOption::DEST_CONSOLE;
} else {
option.destination = OutputOption::DEST_SYSLOG;
}
// ... and set the destination
spec.addOutputOption(option);
manager.process(spec);
}
}
}; // namespace isc::lfc
}; // namespace isc
......@@ -196,6 +196,12 @@ private:
/// @throw RunTimeFail if we can't move the file.
template<typename LeaseObjectType, typename LeaseFileType, typename StorageType>
void processLeases() const;
///@brief Start up the logging system
///
/// @param test_mode indicates if we have have been started from the test
/// system (true) or are running normally (false)
void startLogger(const bool test_mode) const;
};
}; // namespace isc::lfc
......
......@@ -109,7 +109,7 @@ protected:
/// lfcController::launch for details. This is wrapped to provide
/// a single place to update the test_mode throughout the file.
void launch(LFCController lfc_controller, int argc, char* argv[]) {
lfc_controller.launch(argc, argv, false);
lfc_controller.launch(argc, argv, true);
}
private:
......
......@@ -83,9 +83,9 @@ libkea_dhcpsrv_la_SOURCES += host_mgr.cc host_mgr.h
libkea_dhcpsrv_la_SOURCES += key_from_key.h
libkea_dhcpsrv_la_SOURCES += lease.cc lease.h
libkea_dhcpsrv_la_SOURCES += lease_file_loader.h
libkea_dhcpsrv_la_SOURCES += lease_file_stats.h
libkea_dhcpsrv_la_SOURCES += lease_mgr.cc lease_mgr.h
libkea_dhcpsrv_la_SOURCES += lease_mgr_factory.cc lease_mgr_factory.h
libkea_dhcpsrv_la_SOURCES += lease_stats.h
libkea_dhcpsrv_la_SOURCES += logging.cc logging.h
libkea_dhcpsrv_la_SOURCES += logging_info.cc logging_info.h
libkea_dhcpsrv_la_SOURCES += memfile_lease_mgr.cc memfile_lease_mgr.h
......
......@@ -19,7 +19,7 @@
#include <dhcp/duid.h>
#include <dhcpsrv/lease.h>
#include <dhcpsrv/subnet.h>
#include <dhcpsrv/lease_stats.h>
#include <dhcpsrv/lease_file_stats.h>
#include <util/csv_file.h>
#include <stdint.h>
#include <string>
......
......@@ -19,7 +19,7 @@
#include <dhcp/duid.h>
#include <dhcpsrv/lease.h>
#include <dhcpsrv/subnet.h>
#include <dhcpsrv/lease_stats.h>
#include <dhcpsrv/lease_file_stats.h>
#include <util/csv_file.h>
#include <stdint.h>
#include <string>
......
......@@ -12,8 +12,8 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
#ifndef LEASE_STATS_H
#define LEASE_STATS_H
#ifndef LEASE_FILE_STATS_H
#define LEASE_FILE_STATS_H
namespace isc {
namespace dhcp {
......@@ -99,4 +99,4 @@ protected:
} // namespace isc::dhcp
} // namesapce isc
#endif // LEASE_STATS_H
#endif // LEASE_FILE_STATS_H
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