move-only: move logging categories to logging/categories.h
What changed, and why it matters
This commit is a simple code reorganization: it moves the list of logging categories from one header file to a new header file, without changing what the categories are or how they behave. It is purely a structural cleanup to make future work easier.
No security action needed. Treat as normal refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit extracts the BCLog::LogFlags enum and CategoryMask type alias from src/logging.h into a new src/logging/categories.h header, which src/logging.h then includes. The values, names, and conditional DEBUG_LOCKCONTENTION flag are preserved exactly. The change is labeled ‘move-only’ by the author and is intended to remove a future dependency of the kernel module on logging.h.
Changed components
src/logging.hsrc/logging/categories.hInspect captured patch +55 / −38
diff --git a/src/logging.h b/src/logging.h
index 2b4b657d..18eb2c61 100644
--- a/src/logging.h
+++ b/src/logging.h
@@ -7,6 +7,7 @@
#define BITCOIN_LOGGING_H
#include <crypto/siphash.h>
+#include <logging/categories.h> // IWYU pragma: export
#include <threadsafety.h>
#include <tinyformat.h>
#include <util/check.h>
@@ -62,44 +63,6 @@ struct LogCategory {
};
namespace BCLog {
- using CategoryMask = uint64_t;
- enum LogFlags : CategoryMask {
- NONE = CategoryMask{0},
- NET = (CategoryMask{1} << 0),
- TOR = (CategoryMask{1} << 1),
- MEMPOOL = (CategoryMask{1} << 2),
- HTTP = (CategoryMask{1} << 3),
- BENCH = (CategoryMask{1} << 4),
- ZMQ = (CategoryMask{1} << 5),
- WALLETDB = (CategoryMask{1} << 6),
- RPC = (CategoryMask{1} << 7),
- ESTIMATEFEE = (CategoryMask{1} << 8),
- ADDRMAN = (CategoryMask{1} << 9),
- SELECTCOINS = (CategoryMask{1} << 10),
- REINDEX = (CategoryMask{1} << 11),
- CMPCTBLOCK = (CategoryMask{1} << 12),
- RAND = (CategoryMask{1} << 13),
- PRUNE = (CategoryMask{1} << 14),
- PROXY = (CategoryMask{1} << 15),
- MEMPOOLREJ = (CategoryMask{1} << 16),
- LIBEVENT = (CategoryMask{1} << 17),
- COINDB = (CategoryMask{1} << 18),
- QT = (CategoryMask{1} << 19),
- LEVELDB = (CategoryMask{1} << 20),
- VALIDATION = (CategoryMask{1} << 21),
- I2P = (CategoryMask{1} << 22),
- IPC = (CategoryMask{1} << 23),
-#ifdef DEBUG_LOCKCONTENTION
- LOCK = (CategoryMask{1} << 24),
-#endif
- BLOCKSTORAGE = (CategoryMask{1} << 25),
- TXRECONCILIATION = (CategoryMask{1} << 26),
- SCAN = (CategoryMask{1} << 27),
- TXPACKAGES = (CategoryMask{1} << 28),
- KERNEL = (CategoryMask{1} << 29),
- PRIVBROADCAST = (CategoryMask{1} << 30),
- ALL = ~NONE,
- };
enum class Level {
Trace = 0, // High-volume or detailed logging for development/debugging
Debug, // Reasonably noisy logging, but still usable in production
diff --git a/src/logging/categories.h b/src/logging/categories.h
new file mode 100644
index 00000000..dff00ada
--- /dev/null
+++ b/src/logging/categories.h
@@ -0,0 +1,54 @@
+// Copyright (c) The Bitcoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#ifndef BITCOIN_LOGGING_CATEGORIES_H
+#define BITCOIN_LOGGING_CATEGORIES_H
+
+#include <cstdint>
+
+namespace BCLog {
+
+using CategoryMask = uint64_t;
+
+enum LogFlags : CategoryMask {
+ NONE = CategoryMask{0},
+ NET = (CategoryMask{1} << 0),
+ TOR = (CategoryMask{1} << 1),
+ MEMPOOL = (CategoryMask{1} << 2),
+ HTTP = (CategoryMask{1} << 3),
+ BENCH = (CategoryMask{1} << 4),
+ ZMQ = (CategoryMask{1} << 5),
+ WALLETDB = (CategoryMask{1} << 6),
+ RPC = (CategoryMask{1} << 7),
+ ESTIMATEFEE = (CategoryMask{1} << 8),
+ ADDRMAN = (CategoryMask{1} << 9),
+ SELECTCOINS = (CategoryMask{1} << 10),
+ REINDEX = (CategoryMask{1} << 11),
+ CMPCTBLOCK = (CategoryMask{1} << 12),
+ RAND = (CategoryMask{1} << 13),
+ PRUNE = (CategoryMask{1} << 14),
+ PROXY = (CategoryMask{1} << 15),
+ MEMPOOLREJ = (CategoryMask{1} << 16),
+ LIBEVENT = (CategoryMask{1} << 17),
+ COINDB = (CategoryMask{1} << 18),
+ QT = (CategoryMask{1} << 19),
+ LEVELDB = (CategoryMask{1} << 20),
+ VALIDATION = (CategoryMask{1} << 21),
+ I2P = (CategoryMask{1} << 22),
+ IPC = (CategoryMask{1} << 23),
+#ifdef DEBUG_LOCKCONTENTION
+ LOCK = (CategoryMask{1} << 24),
+#endif
+ BLOCKSTORAGE = (CategoryMask{1} << 25),
+ TXRECONCILIATION = (CategoryMask{1} << 26),
+ SCAN = (CategoryMask{1} << 27),
+ TXPACKAGES = (CategoryMask{1} << 28),
+ KERNEL = (CategoryMask{1} << 29),
+ PRIVBROADCAST = (CategoryMask{1} << 30),
+ ALL = ~NONE,
+};
+
+} // namespace BCLog
+
+#endif // BITCOIN_LOGGING_CATEGORIES_H
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.