log, sync: add LOCK logging category, apply it to lock contention

This commit is contained in:
Jon Atack 2021-08-18 12:29:36 +02:00
parent bb9f76a719
commit b7a17444e0
No known key found for this signature in database
GPG key ID: 4F5721B3D0E3921D
4 changed files with 5 additions and 3 deletions

View file

@ -159,6 +159,7 @@ const CLogCategoryDesc LogCategories[] =
{BCLog::VALIDATION, "validation"}, {BCLog::VALIDATION, "validation"},
{BCLog::I2P, "i2p"}, {BCLog::I2P, "i2p"},
{BCLog::IPC, "ipc"}, {BCLog::IPC, "ipc"},
{BCLog::LOCK, "lock"},
{BCLog::ALL, "1"}, {BCLog::ALL, "1"},
{BCLog::ALL, "all"}, {BCLog::ALL, "all"},
}; };

View file

@ -59,6 +59,7 @@ namespace BCLog {
VALIDATION = (1 << 21), VALIDATION = (1 << 21),
I2P = (1 << 22), I2P = (1 << 22),
IPC = (1 << 23), IPC = (1 << 23),
LOCK = (1 << 24),
ALL = ~(uint32_t)0, ALL = ~(uint32_t)0,
}; };

View file

@ -29,8 +29,8 @@ static_assert(false, "thread_local is not supported");
#endif #endif
void PrintLockContention(const char* pszName, const char* pszFile, int nLine) void PrintLockContention(const char* pszName, const char* pszFile, int nLine)
{ {
LogPrintf("LOCKCONTENTION: %s\n", pszName); LogPrint(BCLog::LOCK, "LOCKCONTENTION: %s\n", pszName);
LogPrintf("Locker: %s:%d\n", pszFile, nLine); LogPrint(BCLog::LOCK, "Locker: %s:%d\n", pszFile, nLine);
} }
#endif /* DEBUG_LOCKCONTENTION */ #endif /* DEBUG_LOCKCONTENTION */

View file

@ -57,7 +57,7 @@ class RpcMiscTest(BitcoinTestFramework):
self.log.info("test logging rpc and help") self.log.info("test logging rpc and help")
# Test logging RPC returns the expected number of logging categories. # 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. # Test toggling a logging category on/off/on with the logging RPC.
assert_equal(node.logging()['qt'], True) assert_equal(node.logging()['qt'], True)