1
0
mirror of https://github.com/codership/wsrep-lib.git synced 2025-07-20 01:03:16 +03:00

Add --wsrep-debug-level options for unit tests

This commit is contained in:
Daniele Sciascia
2020-10-05 16:03:33 +02:00
parent abc0e629ee
commit c68ad83aba

View File

@ -26,6 +26,8 @@
* --wsrep-log-file=<file> Write log from wsrep-lib logging facility
* into <file>. If <file> is left empty, the
* log is written into stdout.
* --wsrep-debug-level=<int> Set debug level
* See wsrep::log::debug_level for valid values
*/
#include "wsrep/logger.hpp"
@ -37,6 +39,9 @@
// Log file to write messages logged via wsrep-lib logging facility.
static std::string log_file_name("wsrep-lib_test.log");
static std::ofstream log_file;
// Debug log level for wsrep-lib logging
static std::string debug_log_level;
static void log_fn(wsrep::log::level level,
const char* msg)
@ -59,6 +64,10 @@ static bool parse_arg(const std::string& arg)
{
log_file_name = val;
}
else if (parm == "--wsrep-debug-level")
{
debug_log_level = val;
}
else
{
std::cerr << "Error: Unknown argument " << arg << std::endl;
@ -91,6 +100,14 @@ static bool setup_env(int argc, char* argv[])
<< std::endl;
wsrep::log::logger_fn(log_fn);
}
if (debug_log_level.size())
{
int level = std::stoi(debug_log_level);
std::cout << "Setting debug level '" << level << "'" << std::endl;
wsrep::log::debug_log_level(level);
}
return true;
}