Skip to content

Commit bba596d

Browse files
laanwjPastaPastaPasta
authored andcommitted
Merge bitcoin#19317: Add a left-justified width field to log2_work component for a uniform debug.log output
c858302 Change format of log2_work for uniform output (zero-padded) (jmorgan) Pull request description: Motivation: It's jarring to watch the output of `tail -f ~/btcdata/debug.log` scroll by and very frequently see columns not lining up correctly because `log2_work` somtimes has less precision than 8 digits. Current display: ``` 2020-06-18T02:54:42Z UpdateTip: new best=0000000000000000107f877e4920643f9fb06090fa7551cd1cdd83b857f520aa height=382038 version=0x00000003 log2_work=83.558653 tx=90953616 date='2015-11-04T17:11:44Z' progress=0.166675 cache=117.6MiB(966410txo) 2020-06-18T02:54:51Z UpdateTip: new best=0000000000000000019a4de585d30d1a8cc13c7a1972d11b4945635c9556acb5 height=382039 version=0x00000003 log2_work=83.55868 tx=90955936 date='2015-11-04T17:19:39Z' progress=0.166679 cache=117.9MiB(968799txo) ``` Display with this commit: ``` 2020-06-18T02:54:42Z UpdateTip: new best=0000000000000000107f877e4920643f9fb06090fa7551cd1cdd83b857f520aa height=382038 version=0x00000003 log2_work=83.558653 tx=90953616 date='2015-11-04T17:11:44Z' progress=0.166675 cache=117.6MiB(966410txo) 2020-06-18T02:54:51Z UpdateTip: new best=0000000000000000019a4de585d30d1a8cc13c7a1972d11b4945635c9556acb5 height=382039 version=0x00000003 log2_work=83.55868 tx=90955936 date='2015-11-04T17:19:39Z' progress=0.166679 cache=117.9MiB(968799txo) ``` ACKs for top commit: practicalswift: ACK c858302 -- patch looks great :) achow101: ACK c858302 laanwj: Tested ACK c858302 Tree-SHA512: 16cbe419c4993ad51019c676e8ca409ef1025b803cc598437c780dd7ca003d7e4ad421f451e9a374e0070ee9b3ee601b7aba849e1f346798f9321d1bce5c4401
1 parent 6723381 commit bba596d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/validation.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,12 +1374,12 @@ void CChainState::InvalidChainFound(CBlockIndex* pindexNew)
13741374
pindexBestHeader = m_chain.Tip();
13751375
}
13761376

1377-
LogPrintf("%s: invalid block=%s height=%d log2_work=%.8f date=%s\n", __func__,
1377+
LogPrintf("%s: invalid block=%s height=%d log2_work=%f date=%s\n", __func__,
13781378
pindexNew->GetBlockHash().ToString(), pindexNew->nHeight,
13791379
log(pindexNew->nChainWork.getdouble())/log(2.0), FormatISO8601DateTime(pindexNew->GetBlockTime()));
13801380
CBlockIndex *tip = m_chain.Tip();
13811381
assert (tip);
1382-
LogPrintf("%s: current best=%s height=%d log2_work=%.8f date=%s\n", __func__,
1382+
LogPrintf("%s: current best=%s height=%d log2_work=%f date=%s\n", __func__,
13831383
tip->GetBlockHash().ToString(), m_chain.Height(), log(tip->nChainWork.getdouble())/log(2.0),
13841384
FormatISO8601DateTime(tip->GetBlockTime()));
13851385
CheckForkWarningConditions();
@@ -1391,12 +1391,12 @@ void CChainState::ConflictingChainFound(CBlockIndex* pindexNew)
13911391

13921392
statsClient.inc("warnings.ConflictingChainFound", 1.0f);
13931393

1394-
LogPrintf("%s: conflicting block=%s height=%d log2_work=%.8f date=%s\n", __func__,
1394+
LogPrintf("%s: conflicting block=%s height=%d log2_work=%f date=%s\n", __func__,
13951395
pindexNew->GetBlockHash().ToString(), pindexNew->nHeight,
13961396
log(pindexNew->nChainWork.getdouble())/log(2.0), FormatISO8601DateTime(pindexNew->GetBlockTime()));
13971397
CBlockIndex *tip = m_chain.Tip();
13981398
assert (tip);
1399-
LogPrintf("%s: current best=%s height=%d log2_work=%.8f date=%s\n", __func__,
1399+
LogPrintf("%s: current best=%s height=%d log2_work=%f date=%s\n", __func__,
14001400
tip->GetBlockHash().ToString(), m_chain.Height(), log(tip->nChainWork.getdouble())/log(2.0),
14011401
FormatISO8601DateTime(tip->GetBlockTime()));
14021402
CheckForkWarningConditions();
@@ -2704,7 +2704,7 @@ void CChainState::UpdateTip(const CBlockIndex* pindexNew)
27042704
}
27052705
}
27062706
assert(std::addressof(::ChainstateActive()) == std::addressof(*this));
2707-
LogPrintf("%s: new best=%s height=%d version=0x%08x log2_work=%.8g tx=%lu date='%s' progress=%f cache=%.1fMiB(%utxo) evodb_cache=%.1fMiB%s\n", __func__,
2707+
LogPrintf("%s: new best=%s height=%d version=0x%08x log2_work=%f tx=%lu date='%s' progress=%f cache=%.1fMiB(%utxo) evodb_cache=%.1fMiB%s\n", __func__,
27082708
pindexNew->GetBlockHash().ToString(), pindexNew->nHeight, pindexNew->nVersion,
27092709
log(pindexNew->nChainWork.getdouble())/log(2.0), (unsigned long)pindexNew->nChainTx,
27102710
FormatISO8601DateTime(pindexNew->GetBlockTime()),

0 commit comments

Comments
 (0)