Fix thread-safe behaviour
This commit is contained in:
parent
799c9c4218
commit
07539f7985
@ -7,7 +7,7 @@
|
||||
|
||||
using namespace sc;
|
||||
|
||||
std::mutex logger::_mtx;
|
||||
std::recursive_mutex logger::_mtx;
|
||||
|
||||
logger::logger(const std::string& name, loglevel level)
|
||||
: _level(level), _name(name) {}
|
||||
@ -15,7 +15,6 @@ logger::logger(const std::string& name, loglevel level)
|
||||
void logger::msg(loglevel level, const sc::io::trgb* color,
|
||||
const char* file, int line, const char* func) {
|
||||
if (level >= _level) {
|
||||
std::lock_guard<std::mutex> lock {_mtx};
|
||||
if (_topcall) {
|
||||
write_prefix(level, color, file, line, func);
|
||||
} else {
|
||||
|
@ -45,6 +45,7 @@ namespace sc {
|
||||
const char* file, int line, const char* func,
|
||||
T value, Args... args) {
|
||||
if (level >= _level) {
|
||||
std::lock_guard<std::recursive_mutex> lock {_mtx};
|
||||
if (_topcall) {
|
||||
_topcall = false;
|
||||
write_prefix(level, color, file, line, func);
|
||||
@ -67,7 +68,7 @@ namespace sc {
|
||||
loglevel _level {loglevel::info};
|
||||
bool _topcall {true};
|
||||
std::string _name;
|
||||
static std::mutex _mtx;
|
||||
static std::recursive_mutex _mtx;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user