mirror of
https://github.com/gabime/spdlog.git
synced 2025-01-14 01:32:07 +08:00
wip
This commit is contained in:
parent
6a305df46d
commit
49f707ec93
@ -269,14 +269,25 @@ SPDLOG_INLINE void registry::set_configs(logger_cfgs configs)
|
|||||||
auto cfg_it = configs.loggers.find(logger->name());
|
auto cfg_it = configs.loggers.find(logger->name());
|
||||||
|
|
||||||
// use default config if not found for this logger name
|
// use default config if not found for this logger name
|
||||||
logger_cfg *cfg = cfg_it != configs.loggers.end() ? &cfg_it->second : &configs.default_cfg;
|
|
||||||
if(cfg->level_name.empty()) {
|
logger_cfg *cfg;
|
||||||
cfg->level_name = configs.default_cfg.level_name;
|
if(cfg_it != configs.loggers.end())
|
||||||
|
{
|
||||||
|
cfg = &cfg_it->second;
|
||||||
|
if(cfg->level_name.empty())
|
||||||
|
{
|
||||||
|
cfg->level_name = configs.default_cfg.level_name;
|
||||||
|
}
|
||||||
|
if(cfg->level_name.empty())
|
||||||
|
{
|
||||||
|
cfg->level_name = configs.default_cfg.level_name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cfg = &configs.default_cfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cfg->pattern.empty()) {
|
|
||||||
cfg->pattern = configs.default_cfg.pattern;
|
|
||||||
}
|
|
||||||
|
|
||||||
logger->set_level(level::from_str(cfg->level_name));
|
logger->set_level(level::from_str(cfg->level_name));
|
||||||
logger->set_formatter(details::make_unique<pattern_formatter>(cfg->pattern));
|
logger->set_formatter(details::make_unique<pattern_formatter>(cfg->pattern));
|
||||||
|
@ -29,14 +29,14 @@ class registry
|
|||||||
public:
|
public:
|
||||||
struct logger_cfg
|
struct logger_cfg
|
||||||
{
|
{
|
||||||
std::string level_name = "info";
|
std::string level_name;
|
||||||
std::string pattern = "%+";
|
std::string pattern;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct logger_cfgs
|
struct logger_cfgs
|
||||||
{
|
{
|
||||||
std::unordered_map<std::string, logger_cfg> loggers;
|
std::unordered_map<std::string, logger_cfg> loggers;
|
||||||
logger_cfg default_cfg;
|
logger_cfg default_cfg = {"info", "%+"};
|
||||||
};
|
};
|
||||||
|
|
||||||
registry(const registry &) = delete;
|
registry(const registry &) = delete;
|
||||||
|
Loading…
Reference in New Issue
Block a user