change of scope the name_to_level variable

This commit is contained in:
fegomes 2018-03-09 09:04:44 -03:00
parent c21dd874d1
commit 46f9768599

View File

@ -87,16 +87,6 @@ enum level_enum
off = 6 off = 6
}; };
static std::unordered_map<std::string, level_enum> name_to_level = {
{ "trace" , level::trace },
{ "debug" , level::debug },
{ "info" , level::info },
{ "warning" , level::warn },
{ "error" , level::err },
{ "critical", level::critical },
{ "off" , level::off }
};
#if !defined(SPDLOG_LEVEL_NAMES) #if !defined(SPDLOG_LEVEL_NAMES)
#define SPDLOG_LEVEL_NAMES { "trace", "debug", "info", "warning", "error", "critical", "off" } #define SPDLOG_LEVEL_NAMES { "trace", "debug", "info", "warning", "error", "critical", "off" }
@ -116,6 +106,15 @@ inline const char* to_short_str(spdlog::level::level_enum l)
} }
inline spdlog::level::level_enum to_level_enum(const std::string& name) inline spdlog::level::level_enum to_level_enum(const std::string& name)
{ {
static std::unordered_map<std::string, level_enum> name_to_level = {
{ level_names[0], level::trace },
{ level_names[1], level::debug },
{ level_names[2], level::info },
{ level_names[3], level::warn },
{ level_names[4], level::err },
{ level_names[5], level::critical },
{ level_names[6], level::off }
};
auto ci = name_to_level.find(name); auto ci = name_to_level.find(name);
if (ci != name_to_level.end()) if (ci != name_to_level.end())
{ {