Kea 2.7.6
|
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. | |
virtual | ~LogContentTest () |
void | addString (const string &logger_msg, const string &new_string, const string &label) |
Generates and adds a string to the vector of expected strings. | |
void | addString (const string &new_string) |
Add a string to the vector of expected strings. | |
bool | checkFile () |
check that the requested strings are in the test log file in the requested order. | |
size_t | countFile (const string &exp_string) |
check that the requested string is in the test log file. | |
void | logCheckVerbose (bool talk_a_lot) |
Enables or disables verbose mode. | |
void | remFile () |
remove the test log file | |
Public Attributes | |
vector< string > | exp_strings_ |
bool | verbose_ |
controls whether the checkFile() should print more details. | |
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::DEST_FILE, 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 & | logger_msg, |
const string & | new_string, | ||
const string & | label ) |
Generates and adds a string to the vector of expected strings.
logger_msg | logger message that will be prepended to the string |
new_string | the string used to generate the outcome |
label | packet's label |
Definition at line 121 of file log_utils.cc.
References exp_strings_.
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.
References verbose_.
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 94 of file log_utils.h.
Referenced by addString(), addString(), and checkFile().
|
static |
Definition at line 96 of file log_utils.h.
Referenced by LogContentTest().
|
static |
Definition at line 95 of file log_utils.h.
Referenced by LogContentTest(), checkFile(), countFile(), 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 106 of file log_utils.h.
Referenced by LogContentTest(), checkFile(), countFile(), and logCheckVerbose().