mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-08 10:31:50 -05:00
Add BCLog::Logger::m_category_log_levels data member and getter/setter
Co-authored-by: "klementtan <klementtan@gmail.com>"
This commit is contained in:
parent
2978b387bf
commit
f6c0cc0350
1 changed files with 15 additions and 0 deletions
|
@ -17,6 +17,7 @@
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
static const bool DEFAULT_LOGTIMEMICROS = false;
|
static const bool DEFAULT_LOGTIMEMICROS = false;
|
||||||
|
@ -92,6 +93,9 @@ namespace BCLog {
|
||||||
*/
|
*/
|
||||||
std::atomic_bool m_started_new_line{true};
|
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
|
//! If there is no category-specific log level, all logs with a severity
|
||||||
//! level lower than `m_log_level` will be ignored.
|
//! level lower than `m_log_level` will be ignored.
|
||||||
std::atomic<Level> m_log_level{DEFAULT_LOG_LEVEL};
|
std::atomic<Level> m_log_level{DEFAULT_LOG_LEVEL};
|
||||||
|
@ -148,6 +152,17 @@ namespace BCLog {
|
||||||
|
|
||||||
void ShrinkDebugFile();
|
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(); }
|
Level LogLevel() const { return m_log_level.load(); }
|
||||||
void SetLogLevel(Level level) { m_log_level = level; }
|
void SetLogLevel(Level level) { m_log_level = level; }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue