Skip to content

Commit 2cf8c2c

Browse files
author
MacroFake
committed
Merge bitcoin/bitcoin#25256: logging: fix logging empty thread name
3a171f7 logging: fix logging empty threadname (klementtan) Pull request description: Currently, `leveldb` background thread does not have a thread name and as a result, an empty thread name is logged. This PR fixes this by logging thread name as `"unknown"` if the thread name is empty On master: ```txt 2022-06-02T14:30:38Z [] [leveldb:debug] Generated table #281@0: 1862 keys, 138303 bytes ``` On this PR: ```txt 2022-06-02T14:30:38Z [unknown] [leveldb:debug] Generated table #281@0: 1862 keys, 138303 bytes ``` ACKs for top commit: laanwj: Code review ACK 3a171f7 hebasto: ACK 3a171f7 Tree-SHA512: 0af0fa5c4ddd3640c6dab9595fe9d97f74d0e0f4b41287a6630cf8ac5a21240250e0659ec4ac5a561e888d522f5304bf627104de2aba0fd0a86c1222de0897c2
2 parents 00ce854 + 3a171f7 commit 2cf8c2c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/logging.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,8 @@ void BCLog::Logger::LogPrintStr(const std::string& str, const std::string& loggi
364364
}
365365

366366
if (m_log_threadnames && m_started_new_line) {
367-
str_prefixed.insert(0, "[" + util::ThreadGetInternalName() + "] ");
367+
const auto threadname = util::ThreadGetInternalName();
368+
str_prefixed.insert(0, "[" + (threadname.empty() ? "unknown" : threadname) + "] ");
368369
}
369370

370371
str_prefixed = LogTimestampStr(str_prefixed);

0 commit comments

Comments
 (0)