Kea
1.9.9-git
|
Test class for testing things that emit log entries. More...
#include <log_utils.h>
Public Member Functions | |
LogContentTest () | |
Initializes the logger setup for using in checking log statements. More... | |
virtual | ~LogContentTest () |
void | addString (const string &new_string) |
Add a string to the vector of expected strings. More... | |
bool | checkFile () |
check that the requested strings are in the test log file in the requested order. More... | |
size_t | countFile (const string &exp_string) |
check that the requested string is in the test log file. More... | |
void | logCheckVerbose (bool talk_a_lot) |
Enables or disables verbose mode. More... | |
void | remFile () |
remove the test log file More... | |
Public Attributes | |
vector< string > | exp_strings_ |
bool | verbose_ |
controls whether the checkFile() should print more details. More... | |
Static Public Attributes | |
static const char * | KEA_LOG_CHECK_VERBOSE = "KEA_LOG_CHECK_VERBOSE" |
static const char * | LOG_FILE = "logtest.log" |
Test class for testing things that emit log entries.
This class provides a convenient method for testing out things that emit log entries. The class sets up the logging to log everything into a file and provides a routine to check the expected strings vs the actual log entries. The user needs to call the addString function for each of the strings they expect in the output in the order they will be emitted.
Definition at line 40 of file log_utils.h.
isc::dhcp::test::LogContentTest::LogContentTest | ( | ) |
Initializes the logger setup for using in checking log statements.
Definition at line 17 of file log_utils.cc.
References isc::log::LoggerSpecification::addOutputOption(), isc::log::DEBUG, isc::log::OutputOption::destination, isc::log::OutputOption::filename, isc::log::getRootLoggerName(), KEA_LOG_CHECK_VERBOSE, isc::log::keaLoggerDbglevel(), isc::log::keaLoggerSeverity(), LOG_FILE, isc::log::MAX_DEBUG_LEVEL, isc::log::LoggerManager::process(), remFile(), and verbose_.
|
virtual |
Definition at line 44 of file log_utils.cc.
References remFile().
void isc::dhcp::test::LogContentTest::addString | ( | const string & | new_string | ) |
Add a string to the vector of expected strings.
new_string | the string to add to the end of the vector |
Definition at line 117 of file log_utils.cc.
References exp_strings_.
bool isc::dhcp::test::LogContentTest::checkFile | ( | ) |
check that the requested strings are in the test log file in the requested order.
This routine expects that the caller has properly set up the vector of expected strings by calling addString() with the necessary strings.
Definition at line 48 of file log_utils.cc.
References exp_strings_, LOG_FILE, and verbose_.
size_t isc::dhcp::test::LogContentTest::countFile | ( | const string & | exp_string | ) |
check that the requested string is in the test log file.
exp_string | the string to be searched |
Definition at line 84 of file log_utils.cc.
|
inline |
Enables or disables verbose mode.
See verbose_ for details.
talk_a_lot | (true - as the name says, false - shut up) |
Definition at line 78 of file log_utils.h.
void isc::dhcp::test::LogContentTest::remFile | ( | ) |
remove the test log file
Definition at line 113 of file log_utils.cc.
References LOG_FILE.
Referenced by LogContentTest(), and ~LogContentTest().
vector<string> isc::dhcp::test::LogContentTest::exp_strings_ |
Definition at line 88 of file log_utils.h.
Referenced by addString(), and checkFile().
|
static |
Definition at line 90 of file log_utils.h.
Referenced by LogContentTest().
|
static |
Definition at line 89 of file log_utils.h.
Referenced by checkFile(), countFile(), LogContentTest(), and remFile().
bool isc::dhcp::test::LogContentTest::verbose_ |
controls whether the checkFile() should print more details.
If set to true, checkFile() will print each expected line, each logged line and will print out a failure message if those two do not match. Also, a final verdict is printed. Everything is printed on stdout. The default is false but can be overwritten by setting the KEA_LOG_CHECK_VERBOSE environment variable.
Definition at line 100 of file log_utils.h.
Referenced by checkFile(), countFile(), and LogContentTest().