Skip to content

Commit d9cc2ea

Browse files
committed
merge bitcoin#23104: Avoid breaking single log lines over multiple lines in the log file
1 parent 479ae82 commit d9cc2ea

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

src/sync.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,34 +94,36 @@ LockData& GetLockData() {
9494

9595
static void potential_deadlock_detected(const LockPair& mismatch, const LockStack& s1, const LockStack& s2)
9696
{
97-
std::string strOutput = "";
98-
strOutput += "POTENTIAL DEADLOCK DETECTED\n";
99-
strOutput += "Previous lock order was:\n";
97+
std::string log_message{};
98+
log_message += "POTENTIAL DEADLOCK DETECTED\n";
99+
log_message += "Previous lock order was:\n";
100100
for (const LockStackItem& i : s1) {
101+
std::string prefix{};
101102
if (i.first == mismatch.first) {
102-
strOutput += " (1)";
103+
prefix = " (1)";
103104
}
104105
if (i.first == mismatch.second) {
105-
strOutput += " (2)";
106+
prefix = " (2)";
106107
}
107-
strOutput += strprintf(" %s\n", i.second.ToString());
108+
log_message += strprintf("%s %s\n", prefix, i.second.ToString());
108109
}
109110

110111
std::string mutex_a, mutex_b;
111-
strOutput += "Current lock order is:\n";
112+
log_message += "Current lock order is:\n";
112113
for (const LockStackItem& i : s2) {
114+
std::string prefix{};
113115
if (i.first == mismatch.first) {
114-
strOutput += " (1)";
116+
prefix = " (1)";
115117
mutex_a = i.second.Name();
116118
}
117119
if (i.first == mismatch.second) {
118-
strOutput += " (2)";
120+
prefix = " (2)";
119121
mutex_b = i.second.Name();
120122
}
121-
strOutput += strprintf(" %s\n", i.second.ToString());
123+
log_message += strprintf("%s %s\n", prefix, i.second.ToString());
122124
}
123125

124-
LogPrintf("%s\n", strOutput);
126+
LogPrintf("%s\n", log_message);
125127

126128
if (g_debug_lockorder_abort) {
127129
tfm::format(std::cerr, "Assertion failed: detected inconsistent lock order for %s, details in debug log.\n", s2.back().second.ToString());

src/wallet/coinselection.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,15 +340,15 @@ bool KnapsackSolver(const CAmount& nTargetValue, std::vector<OutputGroup>& group
340340
util::insert(setCoinsRet, lowest_larger->m_outputs);
341341
nValueRet += lowest_larger->m_value;
342342
} else {
343-
std::string s = "CWallet::SelectCoinsMinConf best subset: ";
343+
std::string log_message{"Coin selection best subset: "};
344344
for (unsigned int i = 0; i < applicable_groups.size(); i++) {
345345
if (vfBest[i]) {
346346
util::insert(setCoinsRet, applicable_groups[i].m_outputs);
347347
nValueRet += applicable_groups[i].m_value;
348-
s += FormatMoney(applicable_groups[i].m_value) + " ";
348+
log_message += strprintf("%s ", FormatMoney(applicable_groups[i].m_value));
349349
}
350350
}
351-
LogPrint(BCLog::SELECTCOINS, "%s - total %s\n", s, FormatMoney(nBest));
351+
LogPrint(BCLog::SELECTCOINS, "%stotal %s\n", log_message, FormatMoney(nBest));
352352
}
353353

354354
// There is no change in PS, so we know the fee beforehand,

0 commit comments

Comments
 (0)