From 7592a48587d001def84357b87865b95f1d325898 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Fri, 18 Jan 2019 18:11:30 +0100 Subject: [PATCH] Avoid using map for Logger::MessageSeverity --- rwengine/src/core/Logger.cpp | 9 ++------- rwengine/src/core/Logger.hpp | 4 +++- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/rwengine/src/core/Logger.cpp b/rwengine/src/core/Logger.cpp index 70d27fe8..4b44f6c9 100644 --- a/rwengine/src/core/Logger.cpp +++ b/rwengine/src/core/Logger.cpp @@ -38,12 +38,7 @@ void Logger::verbose(const std::string& component, const std::string& message) { log(component, Logger::Verbose, message); } -std::map severityStr{{Logger::Error, 'E'}, - {Logger::Warning, 'W'}, - {Logger::Info, 'I'}, - {Logger::Verbose, 'V'}}; - void StdOutReceiver::messageReceived(const Logger::LogMessage& message) { - std::cout << severityStr[message.severity] << " [" << message.component - << "] " << message.message << '\n'; + std::cout << Logger::messageSeverityName[message.severity] << " [" + << message.component << "] " << message.message << '\n'; } diff --git a/rwengine/src/core/Logger.hpp b/rwengine/src/core/Logger.hpp index b18b5294..e75c0ced 100644 --- a/rwengine/src/core/Logger.hpp +++ b/rwengine/src/core/Logger.hpp @@ -1,6 +1,7 @@ #ifndef _RWENGINE_LOGGER_HPP_ #define _RWENGINE_LOGGER_HPP_ +#include #include #include #include @@ -13,7 +14,8 @@ */ class Logger { public: - enum MessageSeverity { Verbose, Info, Warning, Error }; + enum MessageSeverity { Verbose = 0, Info, Warning, Error}; + static constexpr std::array messageSeverityName{{'V', 'I', 'W', 'E'}}; struct LogMessage { /// The component that produced the message