diff options
author | gabime <gmelman1@gmail.com> | 2019-12-21 14:29:03 +0300 |
---|---|---|
committer | gabime <gmelman1@gmail.com> | 2019-12-21 14:29:03 +0300 |
commit | 65ada3739971445c2658fa46cc6cff35d2f15950 (patch) | |
tree | 2068ed4221ed9f2d24c43afddbe42f78a9ce7d29 /include/spdlog/cfg/env.h | |
parent | 9f539d70286c44c71a043f74597984d80e3d0faf (diff) |
refactor and and support for init from argv
Diffstat (limited to 'include/spdlog/cfg/env.h')
-rw-r--r-- | include/spdlog/cfg/env.h | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/include/spdlog/cfg/env.h b/include/spdlog/cfg/env.h index 9a74f999..5ef86f99 100644 --- a/include/spdlog/cfg/env.h +++ b/include/spdlog/cfg/env.h @@ -2,10 +2,8 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) #pragma once - -#include <spdlog/common.h> -#include <string> -#include <unordered_map> +#include <spdlog/cfg/text_loader.h> +#include <spdlog/details/os.h> // // Init levels and patterns from env variables SPDLOG_LEVEL @@ -24,11 +22,12 @@ // export SPDLOG_LEVEL="off,logger1=debug,logger2=info" namespace spdlog { -namespace env { -void load_levels(); -} // namespace env +namespace cfg { +void init_from_env() +{ + auto cfg = details::os::getenv("SPDLOG_LEVEL"); + auto levels = text_loader::load_levels(cfg); + spdlog::details::registry::instance().set_levels(levels); +} +} // namespace cfg } // namespace spdlog - -#ifdef SPDLOG_HEADER_ONLY -#include "env-inl.h" -#endif // SPDLOG_HEADER_ONLY |