mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-29 23:33:33 +02:00
Merge bitcoin/bitcoin#34865: logging: better use of log::Entry internally
c5ec2d5313logging: replace FormatLogStrInPlace with Format (stickies-v)3b92ec2036logging: replace BufferedLog with log::Entry (stickies-v)8115001cd4logging: pass log::Entry through to logging functions (stickies-v)b414913c73util: add timestamp and thread_name to log::Entry (stickies-v)8a55b17751util: make SourceLocation constructor explicit (stickies-v) Pull request description: Preparatory work to enable struct-based logging for kernel (#34374), but I think it's a mild improvement by itself too. #34465 introduced `util::log::Entry`. This PR updates some internal functions and structs to make better use of that new plumbing. Mostly a refactor, except for very minor timing differences for `timestamp` and `mocktime` which are now uniformly captured at `Entry` generation. ACKs for top commit: maflcko: review ACKc5ec2d5313🚐 ryanofsky: Code review ACKc5ec2d5313. Just suggested changes since last review: adding (void) std::move, making SourceLocation constructor explicit, dropping BufferedLog struct. Overall PR is a nice code simplification, and I don't think it has downsides other than buffered logs now containing [ignored](https://github.com/bitcoin/bitcoin/pull/34865#discussion_r3054379230) `should_ratelimit` fields, which can be fixed in a followup by separating log entries from log options. sedited: ACKc5ec2d5313Tree-SHA512: 3943f380a426b2c1b405226f231db51548c737467a278936b36a4cc738e01a790258f0886817d7caa1dbba7874f2e7f9ad93c36a137fa35f721f2d988b9863aa
This commit is contained in:
@@ -110,7 +110,7 @@ BOOST_AUTO_TEST_CASE(logging_timer)
|
||||
BOOST_CHECK_EQUAL(micro_timer.LogMsg("msg").substr(0, result_prefix.size()), result_prefix);
|
||||
}
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(logging_LogPrintStr, LogSetup)
|
||||
BOOST_FIXTURE_TEST_CASE(logging_LogPrint, LogSetup)
|
||||
{
|
||||
LogInstance().m_log_sourcelocations = true;
|
||||
|
||||
@@ -134,7 +134,7 @@ BOOST_FIXTURE_TEST_CASE(logging_LogPrintStr, LogSetup)
|
||||
std::vector<std::string> expected;
|
||||
for (auto& [msg, category, level, prefix, loc] : cases) {
|
||||
expected.push_back(tfm::format("[%s:%s] [%s] %s%s", util::RemovePrefix(loc.file_name(), "./"), loc.line(), loc.function_name_short(), prefix, msg));
|
||||
LogInstance().LogPrintStr(msg, std::move(loc), category, level, /*should_ratelimit=*/false);
|
||||
LogInstance().LogPrint({.category = category, .level = level, .should_ratelimit = false, .source_loc = std::move(loc), .message = msg});
|
||||
}
|
||||
std::vector<std::string> log_lines{ReadDebugLogLines()};
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(log_lines.begin(), log_lines.end(), expected.begin(), expected.end());
|
||||
|
||||
Reference in New Issue
Block a user