Cleaned level loading from env var

This commit is contained in:
gabime
2020-09-27 02:08:24 +03:00
parent 7542e42e4f
commit 8923922f30
7 changed files with 51 additions and 48 deletions

View File

@@ -27,6 +27,7 @@ class periodic_worker;
class SPDLOG_API registry
{
public:
using log_levels = std::unordered_map<std::string, level::level_enum>;
registry(const registry &) = delete;
registry &operator=(const registry &) = delete;
@@ -79,7 +80,8 @@ public:
void set_automatic_registration(bool automatic_registration);
void set_levels(std::unordered_map<std::string, spdlog::level::level_enum> levels);
// set levels for all existing/future loggers. global_level can be null if should not set.
void set_levels(log_levels levels, level::level_enum *global_level);
static registry &instance();
@@ -93,7 +95,7 @@ private:
std::mutex logger_map_mutex_, flusher_mutex_;
std::recursive_mutex tp_mutex_;
std::unordered_map<std::string, std::shared_ptr<logger>> loggers_;
std::unordered_map<std::string, spdlog::level::level_enum> cfg_levels_;
log_levels log_levels_;
std::unique_ptr<formatter> formatter_;
spdlog::level::level_enum global_log_level_ = level::info;
level::level_enum flush_level_ = level::off;