merge bitcoin#23104: Avoid breaking single log lines over multiple lines in the log file

This commit is contained in:
Kittywhiskers Van Gogh 2024-11-20 17:26:32 +00:00
parent 479ae82ecc
commit d9cc2ea178
No known key found for this signature in database
GPG Key ID: 30CD0C065E5C4AAD
2 changed files with 16 additions and 14 deletions

View File

@ -94,34 +94,36 @@ LockData& GetLockData() {
static void potential_deadlock_detected(const LockPair& mismatch, const LockStack& s1, const LockStack& s2) static void potential_deadlock_detected(const LockPair& mismatch, const LockStack& s1, const LockStack& s2)
{ {
std::string strOutput = ""; std::string log_message{};
strOutput += "POTENTIAL DEADLOCK DETECTED\n"; log_message += "POTENTIAL DEADLOCK DETECTED\n";
strOutput += "Previous lock order was:\n"; log_message += "Previous lock order was:\n";
for (const LockStackItem& i : s1) { for (const LockStackItem& i : s1) {
std::string prefix{};
if (i.first == mismatch.first) { if (i.first == mismatch.first) {
strOutput += " (1)"; prefix = " (1)";
} }
if (i.first == mismatch.second) { if (i.first == mismatch.second) {
strOutput += " (2)"; prefix = " (2)";
} }
strOutput += strprintf(" %s\n", i.second.ToString()); log_message += strprintf("%s %s\n", prefix, i.second.ToString());
} }
std::string mutex_a, mutex_b; std::string mutex_a, mutex_b;
strOutput += "Current lock order is:\n"; log_message += "Current lock order is:\n";
for (const LockStackItem& i : s2) { for (const LockStackItem& i : s2) {
std::string prefix{};
if (i.first == mismatch.first) { if (i.first == mismatch.first) {
strOutput += " (1)"; prefix = " (1)";
mutex_a = i.second.Name(); mutex_a = i.second.Name();
} }
if (i.first == mismatch.second) { if (i.first == mismatch.second) {
strOutput += " (2)"; prefix = " (2)";
mutex_b = i.second.Name(); mutex_b = i.second.Name();
} }
strOutput += strprintf(" %s\n", i.second.ToString()); log_message += strprintf("%s %s\n", prefix, i.second.ToString());
} }
LogPrintf("%s\n", strOutput); LogPrintf("%s\n", log_message);
if (g_debug_lockorder_abort) { if (g_debug_lockorder_abort) {
tfm::format(std::cerr, "Assertion failed: detected inconsistent lock order for %s, details in debug log.\n", s2.back().second.ToString()); tfm::format(std::cerr, "Assertion failed: detected inconsistent lock order for %s, details in debug log.\n", s2.back().second.ToString());

View File

@ -340,15 +340,15 @@ bool KnapsackSolver(const CAmount& nTargetValue, std::vector<OutputGroup>& group
util::insert(setCoinsRet, lowest_larger->m_outputs); util::insert(setCoinsRet, lowest_larger->m_outputs);
nValueRet += lowest_larger->m_value; nValueRet += lowest_larger->m_value;
} else { } else {
std::string s = "CWallet::SelectCoinsMinConf best subset: "; std::string log_message{"Coin selection best subset: "};
for (unsigned int i = 0; i < applicable_groups.size(); i++) { for (unsigned int i = 0; i < applicable_groups.size(); i++) {
if (vfBest[i]) { if (vfBest[i]) {
util::insert(setCoinsRet, applicable_groups[i].m_outputs); util::insert(setCoinsRet, applicable_groups[i].m_outputs);
nValueRet += applicable_groups[i].m_value; nValueRet += applicable_groups[i].m_value;
s += FormatMoney(applicable_groups[i].m_value) + " "; log_message += strprintf("%s ", FormatMoney(applicable_groups[i].m_value));
} }
} }
LogPrint(BCLog::SELECTCOINS, "%s - total %s\n", s, FormatMoney(nBest)); LogPrint(BCLog::SELECTCOINS, "%stotal %s\n", log_message, FormatMoney(nBest));
} }
// There is no change in PS, so we know the fee beforehand, // There is no change in PS, so we know the fee beforehand,