mirror of
https://github.com/gabime/spdlog.git
synced 2025-01-13 09:20:25 +08:00
rename function
This commit is contained in:
parent
d70d5aa9d8
commit
13ebfc0779
@ -79,7 +79,7 @@ SPDLOG_INLINE std::unordered_map<std::string, std::string> extract_key_vals_(con
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline details::registry::logger_levels levels_from_string_(const std::string& input)
|
inline details::registry::logger_levels extract_levels_(const std::string& input)
|
||||||
{
|
{
|
||||||
auto key_vals = extract_key_vals_(input);
|
auto key_vals = extract_key_vals_(input);
|
||||||
details::registry::logger_levels rv;
|
details::registry::logger_levels rv;
|
||||||
@ -110,7 +110,7 @@ inline details::registry::logger_levels levels_from_string_(const std::string& i
|
|||||||
|
|
||||||
SPDLOG_INLINE void load_levels()
|
SPDLOG_INLINE void load_levels()
|
||||||
{
|
{
|
||||||
auto levels = levels_from_string_(details::os::getenv("SPDLOG_LEVEL"));
|
auto levels = extract_levels_(details::os::getenv("SPDLOG_LEVEL"));
|
||||||
spdlog::details::registry::instance().set_levels(levels);
|
spdlog::details::registry::instance().set_levels(levels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
namespace spdlog {
|
namespace spdlog {
|
||||||
namespace env {
|
namespace env {
|
||||||
void load_levels();
|
void load_levels();
|
||||||
}
|
} // namespace env
|
||||||
} // namespace spdlog
|
} // namespace spdlog
|
||||||
|
|
||||||
#ifdef SPDLOG_HEADER_ONLY
|
#ifdef SPDLOG_HEADER_ONLY
|
||||||
|
@ -538,14 +538,16 @@ SPDLOG_INLINE filename_t dir_name(filename_t path)
|
|||||||
|
|
||||||
std::string SPDLOG_INLINE getenv(const char *field)
|
std::string SPDLOG_INLINE getenv(const char *field)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
#if defined(__cplusplus_winrt)
|
#if defined(__cplusplus_winrt)
|
||||||
SPDLOG_THROW(spdlog_ex("getenv is not supported under uwp"));
|
return std::string{}; //not supported under uwp
|
||||||
#endif
|
#else
|
||||||
#if defined(_MSC_VER) && !defined(__cplusplus_winrt)
|
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
char buf[128];
|
char buf[128];
|
||||||
bool ok = ::getenv_s(&len, buf, sizeof(buf), field) == 0;
|
bool ok = ::getenv_s(&len, buf, sizeof(buf), field) == 0;
|
||||||
return ok ? buf : std::string{};
|
return ok ? buf : std::string{};
|
||||||
|
#endif
|
||||||
#else // revert to getenv
|
#else // revert to getenv
|
||||||
char *buf = ::getenv(field);
|
char *buf = ::getenv(field);
|
||||||
return buf ? buf : std::string{};
|
return buf ? buf : std::string{};
|
||||||
|
Loading…
Reference in New Issue
Block a user