diff --git a/src/utilities/core/Logger.cpp b/src/utilities/core/Logger.cpp index ec02b8d86ac..020f70b4135 100644 --- a/src/utilities/core/Logger.cpp +++ b/src/utilities/core/Logger.cpp @@ -66,9 +66,10 @@ LoggerType& Logger::loggerFromChannel(const LogChannel& logChannel) { std::unique_lock l2{m_mutex}; //LoggerType newLogger(boost::log::keywords::channel = logChannel, boost::log::keywords::severity = Debug); - auto [it, inserted] = m_loggerMap.try_emplace(logChannel, LoggerType(boost::log::keywords::channel = logChannel)); + // No need for try_emplace, this we checked it wasn't in the map + auto [it2, inserted] = m_loggerMap.emplace(logChannel, LoggerType(boost::log::keywords::channel = logChannel)); - return it->second; + return it2->second; } return it->second; diff --git a/src/utilities/core/Logger.hpp b/src/utilities/core/Logger.hpp index e9d4ae6f8cd..6c848a472fa 100644 --- a/src/utilities/core/Logger.hpp +++ b/src/utilities/core/Logger.hpp @@ -22,8 +22,10 @@ #include /// defines method logChannel() to get a logger for a class -#define REGISTER_LOGGER(__logChannel__) \ - static openstudio::LogChannel logChannel() { return __logChannel__; } +#define REGISTER_LOGGER(__logChannel__) \ + static openstudio::LogChannel logChannel() { \ + return __logChannel__; \ + } /// log a message from within a registered class #define LOG(__level__, __message__) LOG_FREE(__level__, logChannel(), __message__);