mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-13 06:04:42 +02:00
Merge bitcoin/bitcoin#34806: refactor: logging: Various API improvements
02b2c41103logging: use util/log.h where possible (Anthony Towns)57d7495fe5IWYU fixes (Anthony Towns)611878b46fscripted-diff: logging: Drop LogAcceptCategory (Anthony Towns)34332dba2futil/log, logging: Provide ShouldDebugLog and ShouldTraceLog instead of a generic ShouldLog (Anthony Towns)abea304dd6logging: Move GetLogCategory into Logger class (Anthony Towns)58113e5833util/log: Rename LogPrintLevel_ into detail_ namespace (Anthony Towns)f69d1ae56dutil/log: Provide util::log::NO_RATE_LIMIT to avoid rate limits (Anthony Towns)72e92d67dflogging: Protect ShrinkDebugFile by m_cs (Anthony Towns)904c0d07bbutil/stdmutex: Drop StdLockGuard (Anthony Towns) Pull request description: `ShrinkDebugFile` now takes the logging mutex for its entire run; though it's only called in init so shouldn't have any races in the first place. Adds a `NO_RATE_LIMIT` tag that can be used with info/warning/error logs to avoid rate-limiting. This allows `LogPrintLevel_` to be restricted to being an internal API. The `GetLogCategory` function is moved out of the global namespace. `ShouldLog` is split into separate `ShouldDebugLog` and `ShouldTraceLog` so that filtering checks are somewhat more enforced via function signature checks. Redundant `LogAcceptCategory` function is removed. More files are pointed at util/log.h instead of logging.h. ACKs for top commit: maflcko: review ACK02b2c41103📅 sedited: Re-ACK02b2c41103l0rinc: untested ACK02b2c41103ryanofsky: Code review ACK 02b2c41103435d8dbaa77a526e484066471b2b8c! Overall a lot of nice improvements here. Tree-SHA512: 3bffdca91afbe5c45a522815fe82e6f4cfa96529a4a243b29aad21234650502d6cac780126b584ee3e7ec129d8fdd50670d8a05036cc5c36e586b8c4c3563970
This commit is contained in:
@@ -14,7 +14,6 @@
|
||||
#include <leveldb/slice.h>
|
||||
#include <leveldb/status.h>
|
||||
#include <leveldb/write_batch.h>
|
||||
#include <logging.h>
|
||||
#include <random.h>
|
||||
#include <serialize.h>
|
||||
#include <span.h>
|
||||
@@ -59,7 +58,7 @@ public:
|
||||
// This code is adapted from posix_logger.h, which is why it is using vsprintf.
|
||||
// Please do not do this in normal code
|
||||
void Logv(const char * format, va_list ap) override {
|
||||
if (!LogAcceptCategory(BCLog::LEVELDB, util::log::Level::Debug)) {
|
||||
if (!util::log::ShouldDebugLog(BCLog::LEVELDB)) {
|
||||
return;
|
||||
}
|
||||
char buffer[500];
|
||||
@@ -288,7 +287,7 @@ CDBWrapper::~CDBWrapper()
|
||||
|
||||
void CDBWrapper::WriteBatch(CDBBatch& batch, bool fSync)
|
||||
{
|
||||
const bool log_memory = LogAcceptCategory(BCLog::LEVELDB, util::log::Level::Debug);
|
||||
const bool log_memory = util::log::ShouldDebugLog(BCLog::LEVELDB);
|
||||
double mem_before = 0;
|
||||
if (log_memory) {
|
||||
mem_before = DynamicMemoryUsage() / double(1_MiB);
|
||||
|
||||
Reference in New Issue
Block a user