diff --git a/src/logging.h b/src/logging.h --- a/src/logging.h +++ b/src/logging.h @@ -10,10 +10,9 @@ #include #include #include +#include #include -#include - static const bool DEFAULT_LOGTIMEMICROS = false; static const bool DEFAULT_LOGIPS = false; static const bool DEFAULT_LOGTIMESTAMPS = true; @@ -51,7 +50,7 @@ class Logger { private: FILE *fileout = nullptr; - boost::mutex mutexDebugLog; + std::mutex mutexDebugLog; std::list vMsgsBeforeOpenLog; /** diff --git a/src/logging.cpp b/src/logging.cpp --- a/src/logging.cpp +++ b/src/logging.cpp @@ -6,7 +6,6 @@ #include "logging.h" #include "util.h" -#include "utilstrencodings.h" #include "utiltime.h" bool fLogIPs = DEFAULT_LOGIPS; @@ -34,7 +33,7 @@ } void BCLog::Logger::OpenDebugLog() { - boost::mutex::scoped_lock scoped_lock(mutexDebugLog); + std::lock_guard scoped_lock(mutexDebugLog); assert(fileout == nullptr); fs::path pathDebug = GetDataDir() / "debug.log"; @@ -87,9 +86,9 @@ flag = BCLog::ALL; return true; } - for (unsigned int i = 0; i < ARRAYLEN(LogCategories); i++) { - if (LogCategories[i].category == str) { - flag = LogCategories[i].flag; + for (const CLogCategoryDesc &category_desc : LogCategories) { + if (category_desc.category == str) { + flag = category_desc.flag; return true; } } @@ -99,12 +98,12 @@ std::string ListLogCategories() { std::string ret; int outcount = 0; - for (unsigned int i = 0; i < ARRAYLEN(LogCategories); i++) { + for (const CLogCategoryDesc &category_desc : LogCategories) { // Omit the special cases. - if (LogCategories[i].flag != BCLog::NONE && - LogCategories[i].flag != BCLog::ALL) { + if (category_desc.flag != BCLog::NONE && + category_desc.flag != BCLog::ALL) { if (outcount != 0) ret += ", "; - ret += LogCategories[i].category; + ret += category_desc.category; outcount++; } } @@ -151,7 +150,7 @@ ret = fwrite(strTimestamped.data(), 1, strTimestamped.size(), stdout); fflush(stdout); } else if (fPrintToDebugLog) { - boost::mutex::scoped_lock scoped_lock(mutexDebugLog); + std::lock_guard scoped_lock(mutexDebugLog); // Buffer if we haven't opened the log yet. if (fileout == nullptr) {