martinzink commented on code in PR #1718:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1718#discussion_r1457463615
##########
libminifi/src/core/logging/LoggerConfiguration.cpp:
##########
@@ -145,40 +143,33 @@ void LoggerConfiguration::initialize(const
std::shared_ptr<LoggerProperties> &lo
}
formatter_ = std::make_shared<spdlog::pattern_formatter>(spdlog_pattern);
- std::map<std::string, std::shared_ptr<spdlog::logger>> spdloggers;
- for (auto const & logger_impl : loggers) {
- std::shared_ptr<spdlog::logger> spdlogger;
- auto it = spdloggers.find(logger_impl->name);
- if (it == spdloggers.end()) {
- spdlogger = get_logger(logger_, root_namespace_, logger_impl->name,
formatter_, true);
- spdloggers[logger_impl->name] = spdlogger;
- } else {
- spdlogger = it->second;
- }
- logger_impl->set_delegate(spdlogger);
- }
+ spdlog::apply_all([&](auto spd_logger) {
+ setupSpdLogger(spd_logger, root_namespace_, spd_logger->name(),
formatter_);
+ });
Review Comment:
This is where the magic happens, everything else is basically a
refactor/test fix.
Previously we had a shared_ptr to every LoggerImpl ever created and if we
wanted to modify the settings we iterated it and recreated the underlying
spdlogger.
Now we rely on the registry in spdlog, so if we want to modify the logger
properties we modify the underlying spdlogger without touching the LoggerImpl-s
so we dont need a shared_ptr for these.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]