mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-13 07:28:59 +01:00
log: Construct global logger on first use
This commit is contained in:
@@ -108,12 +108,12 @@ namespace BCLog {
|
||||
|
||||
} // namespace BCLog
|
||||
|
||||
extern BCLog::Logger* const g_logger;
|
||||
BCLog::Logger& LogInstance();
|
||||
|
||||
/** Return true if log accepts specified category */
|
||||
static inline bool LogAcceptCategory(BCLog::LogFlags category)
|
||||
{
|
||||
return g_logger->WillLogCategory(category);
|
||||
return LogInstance().WillLogCategory(category);
|
||||
}
|
||||
|
||||
/** Returns a string with the log categories. */
|
||||
@@ -132,7 +132,7 @@ bool GetLogCategory(BCLog::LogFlags& flag, const std::string& str);
|
||||
template <typename... Args>
|
||||
static inline void LogPrintf(const char* fmt, const Args&... args)
|
||||
{
|
||||
if (g_logger->Enabled()) {
|
||||
if (LogInstance().Enabled()) {
|
||||
std::string log_msg;
|
||||
try {
|
||||
log_msg = tfm::format(fmt, args...);
|
||||
@@ -140,7 +140,7 @@ static inline void LogPrintf(const char* fmt, const Args&... args)
|
||||
/* Original format string will have newline so don't add one here */
|
||||
log_msg = "Error \"" + std::string(fmterr.what()) + "\" while formatting log message: " + fmt;
|
||||
}
|
||||
g_logger->LogPrintStr(log_msg);
|
||||
LogInstance().LogPrintStr(log_msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user