diff options
author | gabime <gmelman1@gmail.com> | 2019-12-11 02:24:51 +0300 |
---|---|---|
committer | gabime <gmelman1@gmail.com> | 2019-12-11 02:24:51 +0300 |
commit | 2b3000dddce5989127dfbd5d0a5c5a2667c999ff (patch) | |
tree | 6208fa51c3d1dfc8888fe46cff12563d8777acf8 /include/spdlog/cfg/env.h | |
parent | b278baf94ef8f20065fa876c2fadd93c3c2ccedb (diff) |
wip
Diffstat (limited to 'include/spdlog/cfg/env.h')
-rw-r--r-- | include/spdlog/cfg/env.h | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/include/spdlog/cfg/env.h b/include/spdlog/cfg/env.h index b22717d4..c52149eb 100644 --- a/include/spdlog/cfg/env.h +++ b/include/spdlog/cfg/env.h @@ -7,25 +7,36 @@ #include <string> #include <unordered_map> -// config spdlog from environment variables -namespace spdlog { -namespace cfg { -struct logger_cfg -{ - std::string level_name; - std::string pattern; -}; -using cfg_map = std::unordered_map<std::string, logger_cfg>; - -// Init levels and patterns from env variabls SPDLOG_LEVEL & SPDLOG_PATTERN +// +// Init levels and patterns from env variables SPDLOG_LEVEL and SPDLOG_PATTERN. +// Inspired from Rust's "env_logger" crate (https://crates.io/crates/env_logger). +// // Examples: +// +// set global level to debug: // export SPDLOG_LEVEL=debug -// export SPDLOG_LEVEL=logger1=%v,*=[%x] [%l] [%n] %v -// export SPDLOG_LEVEL=logger1=debug,logger2=info,*=error -// export SPDLOG_PATTERN=[%x] [%l] [%n] %v // -// Note: will set the level to info if finds unknown level in SPDLOG_LEVEL -cfg_map from_env(); +// turn off all logging except for logger1: +// export SPDLOG_LEVEL="off,logger1=debug" +// +// turn off all logging except for logger1 and logger2: +// export SPDLOG_LEVEL="off,logger1=debug,logger2=info" +// +// set global pattern: +// export SPDLOG_PATTERN="[%x] [%l] [%n] %v" +// +// set pattern for logger1: +// export SPDLOG_PATTERN="logger1=%v,*=[%x] [%l] [%n] %v" +// +// set global pattern and different pattern for logger1: +// export SPDLOG_PATTERN="[%x] [%l] [%n] %v,logger1=[%u] %v" + +namespace spdlog { +namespace cfg { +namespace env { +void init(); +} + } // namespace cfg } // namespace spdlog |