mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-06 21:57:54 +02:00
scripted-diff: logging: Switch from StdLockGuard to STDLOCK
-BEGIN VERIFY SCRIPT- sed -i 's/StdLockGuard scoped_lock(\(.*\));/STDLOCK(\1);/' src/logging.h src/logging.cpp -END VERIFY SCRIPT-
This commit is contained in:
@@ -53,7 +53,7 @@ static int FileWriteStr(std::string_view str, FILE *fp)
|
||||
|
||||
bool BCLog::Logger::StartLogging()
|
||||
{
|
||||
StdLockGuard scoped_lock(m_cs);
|
||||
STDLOCK(m_cs);
|
||||
|
||||
assert(m_buffering);
|
||||
assert(m_fileout == nullptr);
|
||||
@@ -97,7 +97,7 @@ bool BCLog::Logger::StartLogging()
|
||||
|
||||
void BCLog::Logger::DisconnectTestLogger()
|
||||
{
|
||||
StdLockGuard scoped_lock(m_cs);
|
||||
STDLOCK(m_cs);
|
||||
m_buffering = true;
|
||||
if (m_fileout != nullptr) fclose(m_fileout);
|
||||
m_fileout = nullptr;
|
||||
@@ -111,7 +111,7 @@ void BCLog::Logger::DisconnectTestLogger()
|
||||
void BCLog::Logger::DisableLogging()
|
||||
{
|
||||
{
|
||||
StdLockGuard scoped_lock(m_cs);
|
||||
STDLOCK(m_cs);
|
||||
assert(m_buffering);
|
||||
assert(m_print_callbacks.empty());
|
||||
}
|
||||
@@ -159,7 +159,7 @@ bool BCLog::Logger::WillLogCategoryLevel(BCLog::LogFlags category, BCLog::Level
|
||||
|
||||
if (!WillLogCategory(category)) return false;
|
||||
|
||||
StdLockGuard scoped_lock(m_cs);
|
||||
STDLOCK(m_cs);
|
||||
const auto it{m_category_log_levels.find(category)};
|
||||
return level >= (it == m_category_log_levels.end() ? LogLevel() : it->second);
|
||||
}
|
||||
@@ -392,7 +392,7 @@ BCLog::LogRateLimiter::Status BCLog::LogRateLimiter::Consume(
|
||||
const SourceLocation& source_loc,
|
||||
const std::string& str)
|
||||
{
|
||||
StdLockGuard scoped_lock(m_mutex);
|
||||
STDLOCK(m_mutex);
|
||||
auto& stats{m_source_locations.try_emplace(source_loc, m_max_bytes).first->second};
|
||||
Status status{stats.m_dropped_bytes > 0 ? Status::STILL_SUPPRESSED : Status::UNSUPPRESSED};
|
||||
|
||||
@@ -423,7 +423,7 @@ void BCLog::Logger::FormatLogStrInPlace(std::string& str, BCLog::LogFlags catego
|
||||
|
||||
void BCLog::Logger::LogPrintStr(std::string_view str, SourceLocation&& source_loc, BCLog::LogFlags category, BCLog::Level level, bool should_ratelimit)
|
||||
{
|
||||
StdLockGuard scoped_lock(m_cs);
|
||||
STDLOCK(m_cs);
|
||||
return LogPrintStr_(str, std::move(source_loc), category, level, should_ratelimit);
|
||||
}
|
||||
|
||||
@@ -556,7 +556,7 @@ void BCLog::LogRateLimiter::Reset()
|
||||
{
|
||||
decltype(m_source_locations) source_locations;
|
||||
{
|
||||
StdLockGuard scoped_lock(m_mutex);
|
||||
STDLOCK(m_mutex);
|
||||
source_locations.swap(m_source_locations);
|
||||
m_suppression_active = false;
|
||||
}
|
||||
@@ -598,7 +598,7 @@ bool BCLog::Logger::SetCategoryLogLevel(std::string_view category_str, std::stri
|
||||
const auto level = GetLogLevel(level_str);
|
||||
if (!level.has_value() || level.value() > MAX_USER_SETABLE_SEVERITY_LEVEL) return false;
|
||||
|
||||
StdLockGuard scoped_lock(m_cs);
|
||||
STDLOCK(m_cs);
|
||||
m_category_log_levels[flag] = level.value();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -192,14 +192,14 @@ namespace BCLog {
|
||||
/** Returns whether logs will be written to any output */
|
||||
bool Enabled() const EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
|
||||
{
|
||||
StdLockGuard scoped_lock(m_cs);
|
||||
STDLOCK(m_cs);
|
||||
return m_buffering || m_print_to_console || m_print_to_file || !m_print_callbacks.empty();
|
||||
}
|
||||
|
||||
/** Connect a slot to the print signal and return the connection */
|
||||
std::list<std::function<void(const std::string&)>>::iterator PushBackCallback(std::function<void(const std::string&)> fun) EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
|
||||
{
|
||||
StdLockGuard scoped_lock(m_cs);
|
||||
STDLOCK(m_cs);
|
||||
m_print_callbacks.push_back(std::move(fun));
|
||||
return --m_print_callbacks.end();
|
||||
}
|
||||
@@ -207,13 +207,13 @@ namespace BCLog {
|
||||
/** Delete a connection */
|
||||
void DeleteCallback(std::list<std::function<void(const std::string&)>>::iterator it) EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
|
||||
{
|
||||
StdLockGuard scoped_lock(m_cs);
|
||||
STDLOCK(m_cs);
|
||||
m_print_callbacks.erase(it);
|
||||
}
|
||||
|
||||
size_t NumConnections() EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
|
||||
{
|
||||
StdLockGuard scoped_lock(m_cs);
|
||||
STDLOCK(m_cs);
|
||||
return m_print_callbacks.size();
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ namespace BCLog {
|
||||
|
||||
void SetRateLimiting(std::shared_ptr<LogRateLimiter> limiter) EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
|
||||
{
|
||||
StdLockGuard scoped_lock(m_cs);
|
||||
STDLOCK(m_cs);
|
||||
m_limiter = std::move(limiter);
|
||||
}
|
||||
|
||||
@@ -240,17 +240,17 @@ namespace BCLog {
|
||||
|
||||
std::unordered_map<LogFlags, Level> CategoryLevels() const EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
|
||||
{
|
||||
StdLockGuard scoped_lock(m_cs);
|
||||
STDLOCK(m_cs);
|
||||
return m_category_log_levels;
|
||||
}
|
||||
void SetCategoryLogLevel(const std::unordered_map<LogFlags, Level>& levels) EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
|
||||
{
|
||||
StdLockGuard scoped_lock(m_cs);
|
||||
STDLOCK(m_cs);
|
||||
m_category_log_levels = levels;
|
||||
}
|
||||
void AddCategoryLogLevel(LogFlags category, Level level) EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
|
||||
{
|
||||
StdLockGuard scoped_lock(m_cs);
|
||||
STDLOCK(m_cs);
|
||||
m_category_log_levels[category] = level;
|
||||
}
|
||||
bool SetCategoryLogLevel(std::string_view category_str, std::string_view level_str) EXCLUSIVE_LOCKS_REQUIRED(!m_cs);
|
||||
|
||||
Reference in New Issue
Block a user