From c68ad83aba4f1838047a84bcbf32e8d18eec6421 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Mon, 5 Oct 2020 16:03:33 +0200 Subject: [PATCH] Add --wsrep-debug-level options for unit tests --- test/wsrep-lib_test.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/test/wsrep-lib_test.cpp b/test/wsrep-lib_test.cpp index 575a2d2..5f547cf 100644 --- a/test/wsrep-lib_test.cpp +++ b/test/wsrep-lib_test.cpp @@ -23,9 +23,11 @@ * * Commandline arguments: * - * --wsrep-log-file= Write log from wsrep-lib logging facility - * into . If is left empty, the - * log is written into stdout. + * --wsrep-log-file= Write log from wsrep-lib logging facility + * into . If is left empty, the + * log is written into stdout. + * --wsrep-debug-level= 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; }