diff options
author | Jon Atack <jon@atack.com> | 2022-08-18 12:17:16 +0200 |
---|---|---|
committer | Jon Atack <jon@atack.com> | 2022-08-20 11:30:50 +0200 |
commit | f6c0cc03509255ffa4dfd6e2822fce840dd0b181 (patch) | |
tree | 76563c50e734b9435a2af263851e369f2b9f914a /src/logging.h | |
parent | 2978b387bffc226fb1eaca4d30f24a0deedb2a36 (diff) | |
download | bitcoin-f6c0cc03509255ffa4dfd6e2822fce840dd0b181.tar.xz |
Add BCLog::Logger::m_category_log_levels data member and getter/setter
Co-authored-by: "klementtan <klementtan@gmail.com>"
Diffstat (limited to 'src/logging.h')
-rw-r--r-- | src/logging.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/logging.h b/src/logging.h index e6cf451b55..fd806ce142 100644 --- a/src/logging.h +++ b/src/logging.h @@ -17,6 +17,7 @@ #include <list> #include <mutex> #include <string> +#include <unordered_map> #include <vector> static const bool DEFAULT_LOGTIMEMICROS = false; @@ -92,6 +93,9 @@ namespace BCLog { */ std::atomic_bool m_started_new_line{true}; + //! Category-specific log level. Overrides `m_log_level`. + std::unordered_map<LogFlags, Level> m_category_log_levels GUARDED_BY(m_cs); + //! If there is no category-specific log level, all logs with a severity //! level lower than `m_log_level` will be ignored. std::atomic<Level> m_log_level{DEFAULT_LOG_LEVEL}; @@ -148,6 +152,17 @@ namespace BCLog { void ShrinkDebugFile(); + std::unordered_map<LogFlags, Level> CategoryLevels() const + { + StdLockGuard scoped_lock(m_cs); + return m_category_log_levels; + } + void SetCategoryLogLevel(const std::unordered_map<LogFlags, Level>& levels) + { + StdLockGuard scoped_lock(m_cs); + m_category_log_levels = levels; + } + Level LogLevel() const { return m_log_level.load(); } void SetLogLevel(Level level) { m_log_level = level; } |