From b7a17444e0746c562ae97b26eba431577947b06a Mon Sep 17 00:00:00 2001 From: Jon Atack Date: Wed, 18 Aug 2021 12:29:36 +0200 Subject: log, sync: add LOCK logging category, apply it to lock contention --- src/logging.cpp | 1 + src/logging.h | 1 + src/sync.cpp | 4 ++-- test/functional/rpc_misc.py | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/logging.cpp b/src/logging.cpp index b456108b61..eb2c750296 100644 --- a/src/logging.cpp +++ b/src/logging.cpp @@ -159,6 +159,7 @@ const CLogCategoryDesc LogCategories[] = {BCLog::VALIDATION, "validation"}, {BCLog::I2P, "i2p"}, {BCLog::IPC, "ipc"}, + {BCLog::LOCK, "lock"}, {BCLog::ALL, "1"}, {BCLog::ALL, "all"}, }; diff --git a/src/logging.h b/src/logging.h index 38d73863e7..53a89d28bd 100644 --- a/src/logging.h +++ b/src/logging.h @@ -59,6 +59,7 @@ namespace BCLog { VALIDATION = (1 << 21), I2P = (1 << 22), IPC = (1 << 23), + LOCK = (1 << 24), ALL = ~(uint32_t)0, }; diff --git a/src/sync.cpp b/src/sync.cpp index a2b62c2286..9351417d43 100644 --- a/src/sync.cpp +++ b/src/sync.cpp @@ -29,8 +29,8 @@ static_assert(false, "thread_local is not supported"); #endif void PrintLockContention(const char* pszName, const char* pszFile, int nLine) { - LogPrintf("LOCKCONTENTION: %s\n", pszName); - LogPrintf("Locker: %s:%d\n", pszFile, nLine); + LogPrint(BCLog::LOCK, "LOCKCONTENTION: %s\n", pszName); + LogPrint(BCLog::LOCK, "Locker: %s:%d\n", pszFile, nLine); } #endif /* DEBUG_LOCKCONTENTION */ diff --git a/test/functional/rpc_misc.py b/test/functional/rpc_misc.py index 563f2ea43e..13f33c321f 100755 --- a/test/functional/rpc_misc.py +++ b/test/functional/rpc_misc.py @@ -57,7 +57,7 @@ class RpcMiscTest(BitcoinTestFramework): self.log.info("test logging rpc and help") # Test logging RPC returns the expected number of logging categories. - assert_equal(len(node.logging()), 24) + assert_equal(len(node.logging()), 25) # Test toggling a logging category on/off/on with the logging RPC. assert_equal(node.logging()['qt'], True) -- cgit v1.2.3