Changeset View
Changeset View
Standalone View
Standalone View
src/logging.h
Show All 26 Lines | |||||
enum LogFlags : uint32_t { | enum LogFlags : uint32_t { | ||||
NONE = 0, | NONE = 0, | ||||
NET = (1 << 0), | NET = (1 << 0), | ||||
TOR = (1 << 1), | TOR = (1 << 1), | ||||
MEMPOOL = (1 << 2), | MEMPOOL = (1 << 2), | ||||
HTTP = (1 << 3), | HTTP = (1 << 3), | ||||
BENCH = (1 << 4), | BENCH = (1 << 4), | ||||
ZMQ = (1 << 5), | ZMQ = (1 << 5), | ||||
DB = (1 << 6), | WALLETDB = (1 << 6), | ||||
jasonbcox: This diff is already quite large. Please make this change in another diff. | |||||
FabienAuthorUnsubmitted Done Inline ActionsI will move it to another diff Fabien: I will move it to another diff | |||||
RPC = (1 << 7), | RPC = (1 << 7), | ||||
ESTIMATEFEE = (1 << 8), | ESTIMATEFEE = (1 << 8), | ||||
ADDRMAN = (1 << 9), | ADDRMAN = (1 << 9), | ||||
SELECTCOINS = (1 << 10), | SELECTCOINS = (1 << 10), | ||||
REINDEX = (1 << 11), | REINDEX = (1 << 11), | ||||
CMPCTBLOCK = (1 << 12), | CMPCTBLOCK = (1 << 12), | ||||
RAND = (1 << 13), | RAND = (1 << 13), | ||||
PRUNE = (1 << 14), | PRUNE = (1 << 14), | ||||
PROXY = (1 << 15), | PROXY = (1 << 15), | ||||
MEMPOOLREJ = (1 << 16), | MEMPOOLREJ = (1 << 16), | ||||
LIBEVENT = (1 << 17), | LIBEVENT = (1 << 17), | ||||
COINDB = (1 << 18), | COINDB = (1 << 18), | ||||
QT = (1 << 19), | QT = (1 << 19), | ||||
LEVELDB = (1 << 20), | LEVELDB = (1 << 20), | ||||
SCRIPT = (1 << 21), | |||||
TEST = (1 << 22), | |||||
WALLET = (1 << 23), | |||||
INIT = (1 << 24), | |||||
NOUI = (1 << 25), | |||||
SYNC = (1 << 26), | |||||
UTIL = (1 << 27), | |||||
jasonbcoxUnsubmitted Not Done Inline ActionsThanks for adding these. Please double check that latest Core hasn't reserved any of these so that we do not collide during backports. jasonbcox: Thanks for adding these. Please double check that latest Core hasn't reserved any of these so… | |||||
FabienAuthorUnsubmitted Done Inline ActionsChecked, core has no additional flag Fabien: Checked, core has no additional flag | |||||
ALL = ~uint32_t(0), | ALL = ~uint32_t(0), | ||||
}; | }; | ||||
class Logger { | class Logger { | ||||
private: | private: | ||||
FILE *m_fileout = nullptr; | FILE *m_fileout = nullptr; | ||||
std::mutex m_file_mutex; | std::mutex m_file_mutex; | ||||
std::list<std::string> m_msgs_before_open; | std::list<std::string> m_msgs_before_open; | ||||
Show All 30 Lines | public: | ||||
void ShrinkDebugFile(); | void ShrinkDebugFile(); | ||||
void EnableCategory(LogFlags category); | void EnableCategory(LogFlags category); | ||||
bool EnableCategory(const std::string &str); | bool EnableCategory(const std::string &str); | ||||
void DisableCategory(LogFlags category); | void DisableCategory(LogFlags category); | ||||
bool DisableCategory(const std::string &str); | bool DisableCategory(const std::string &str); | ||||
/** Return true if log accepts specified category */ | /** Return true if log accepts specified category */ | ||||
bool WillLogCategory(LogFlags category) const; | bool WillLogCategory(LogFlags category); | ||||
/** Default for whether ShrinkDebugFile should be run */ | /** Default for whether ShrinkDebugFile should be run */ | ||||
bool DefaultShrinkDebugFile() const; | bool DefaultShrinkDebugFile() const; | ||||
}; | }; | ||||
} // namespace BCLog | } // namespace BCLog | ||||
BCLog::Logger &GetLogger(); | BCLog::Logger &GetLogger(); | ||||
Show All 11 Lines | |||||
#define LogPrint(category, ...) \ | #define LogPrint(category, ...) \ | ||||
do { \ | do { \ | ||||
if (LogAcceptCategory((category))) { \ | if (LogAcceptCategory((category))) { \ | ||||
GetLogger().LogPrintStr(tfm::format(__VA_ARGS__)); \ | GetLogger().LogPrintStr(tfm::format(__VA_ARGS__)); \ | ||||
} \ | } \ | ||||
} while (0) | } while (0) | ||||
#define LogPrintf(...) \ | |||||
do { \ | |||||
GetLogger().LogPrintStr(tfm::format(__VA_ARGS__)); \ | |||||
} while (0) | |||||
#endif // BITCOIN_LOGGING_H | #endif // BITCOIN_LOGGING_H |
This diff is already quite large. Please make this change in another diff.