diff options
author | MarcoFalke <falke.marco@gmail.com> | 2019-01-25 15:54:49 -0500 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2019-01-29 15:30:24 -0500 |
commit | 77777c5624e2f5416d85500e82b7c80e10ed01b6 (patch) | |
tree | b6f69a898835496e248bd1e5d551184e6bbf4b33 /src/logging.h | |
parent | d14ef5721ffcf07321704dc21f1ab9df4952a44d (diff) |
log: Construct global logger on first use
Diffstat (limited to 'src/logging.h')
-rw-r--r-- | src/logging.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/logging.h b/src/logging.h index 0c8e7f5291..ac9d0dc0c7 100644 --- a/src/logging.h +++ b/src/logging.h @@ -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); } } |