diff --git a/src/logger.cpp b/src/logger.cpp index 30e912d..bb51d05 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -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 lock {_mtx}; if (_topcall) { write_prefix(level, color, file, line, func); } else { diff --git a/src/logger.hpp b/src/logger.hpp index 9f6b6dc..f5be8e3 100644 --- a/src/logger.hpp +++ b/src/logger.hpp @@ -45,6 +45,7 @@ namespace sc { const char* file, int line, const char* func, T value, Args... args) { if (level >= _level) { + std::lock_guard 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; }; }