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

Debug log level implementation

Debug log will now filter output based on debug level that is enabled.
This commit is contained in:
mkaruza
2019-02-12 10:44:26 +01:00
committed by Teemu Ollakka
parent 510c7f767f
commit be98517cb3
9 changed files with 131 additions and 74 deletions

View File

@ -25,6 +25,12 @@
#include <iosfwd>
#include <sstream>
#include <atomic>
#define WSREP_LOG_DEBUG(debug_level_fn, debug_level, msg) \
do { \
if (debug_level_fn >= debug_level) wsrep::log_debug() << msg; \
} while (0)
namespace wsrep
{
@ -39,6 +45,14 @@ namespace wsrep
error
};
enum debug_level
{
debug_level_server_state = 1,
debug_level_transaction,
debug_level_streaming,
debug_level_client_state
};
/**
* Signature for user defined logger callback function.
*/
@ -85,6 +99,17 @@ namespace wsrep
* Set user defined logger callback function.
*/
static void logger_fn(logger_fn_type);
/**
* Set debug log level from client
*/
static void debug_log_level(int debug_level);
/**
* Get current debug log level
*/
static int debug_log_level();
private:
log(const log&);
log& operator=(const log&);
@ -94,6 +119,7 @@ namespace wsrep
static wsrep::mutex& mutex_;
static std::ostream& os_;
static logger_fn_type logger_fn_;
static std::atomic_int debug_log_level_;
};
class log_error : public log