Skip to content

Commit

Permalink
No need for try_emplace since we already check it's not in the map (c…
Browse files Browse the repository at this point in the history
…ppcheck / clang format)
  • Loading branch information
jmarrec committed Mar 27, 2024
1 parent bf372b5 commit a13db45
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/utilities/core/Logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions src/utilities/core/Logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
#include <sstream>

/// 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__);
Expand Down

0 comments on commit a13db45

Please sign in to comment.