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

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