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

* Fixes to SST time server state management

* Logging tweaks
* Boolean to tune behavior on exception
This commit is contained in:
Teemu Ollakka
2018-06-22 13:03:12 +03:00
parent 8f0e112c47
commit 1f6a6db1e9
12 changed files with 187 additions and 40 deletions

View File

@ -16,14 +16,33 @@ namespace wsrep
class log
{
public:
log(const std::string& prefix = "INFO")
: prefix_(prefix)
enum level
{
debug,
info,
warning,
error
};
static const char* to_c_string(enum level level)
{
switch (level)
{
case debug: return "debug";
case info: return "info";
case warning: return "warning";
case error: return "error";
};
return "unknown";
}
log(enum wsrep::log::level level, const char* prefix = "")
: level_(level)
, prefix_(prefix)
, oss_()
{ }
~log()
{
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
os_ << prefix_ << ": " << oss_.str() << "\n";
os_ << prefix_ << ": " << oss_.str() << std::endl;
}
template <typename T>
std::ostream& operator<<(const T& val)
@ -31,7 +50,10 @@ namespace wsrep
return (oss_ << val);
}
private:
const std::string prefix_;
log(const log&);
log& operator=(const log&);
enum level level_;
const char* prefix_;
std::ostringstream oss_;
static wsrep::mutex& mutex_;
static std::ostream& os_;
@ -41,28 +63,28 @@ namespace wsrep
{
public:
log_error()
: log("ERROR") { }
: log(error) { }
};
class log_warning : public log
{
public:
log_warning()
: log("WARNING") { }
: log(warning) { }
};
class log_info : public log
{
public:
log_info()
: log("INFO") { }
: log(info) { }
};
class log_debug : public log
{
public:
log_debug()
: log("DEBUG") { }
: log(debug) { }
};
}