Photon 1.0.0
Loading...
Searching...
No Matches
env.h
Go to the documentation of this file.
1// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
2// Distributed under the MIT License (http://opensource.org/licenses/MIT)
3
4#pragma once
7#include <spdlog/details/os.h>
8
9//
10// Init levels and patterns from env variables SPDLOG_LEVEL
11// Inspired from Rust's "env_logger" crate (https://crates.io/crates/env_logger).
12// Note - fallback to "info" level on unrecognized levels
13//
14// Examples:
15//
16// set global level to debug:
17// export SPDLOG_LEVEL=debug
18//
19// turn off all logging except for logger1:
20// export SPDLOG_LEVEL="*=off,logger1=debug"
21//
22
23// turn off all logging except for logger1 and logger2:
24// export SPDLOG_LEVEL="off,logger1=debug,logger2=info"
25
26namespace spdlog
27{
28 namespace cfg
29 {
30 inline void load_env_levels()
31 {
32 auto env_val = details::os::getenv("SPDLOG_LEVEL");
33 if (!env_val.empty())
34 {
35 helpers::load_levels(env_val);
36 }
37 }
38
39 } // namespace cfg
40} // namespace spdlog
SPDLOG_INLINE void load_levels(const std::string &input)
Definition helpers-inl.h:85
void load_env_levels()
Definition env.h:30
std::string SPDLOG_INLINE getenv(const char *field)
Definition os-inl.h:587
Definition async.h:26