Photon 1.0.0
Loading...
Searching...
No Matches
argv.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
8//
9// Init log levels using each argv entry that starts with "SPDLOG_LEVEL="
10//
11// set all loggers to debug level:
12// example.exe "SPDLOG_LEVEL=debug"
13
14// set logger1 to trace level
15// example.exe "SPDLOG_LEVEL=logger1=trace"
16
17// turn off all logging except for logger1 and logger2:
18// example.exe "SPDLOG_LEVEL=off,logger1=debug,logger2=info"
19
20namespace spdlog
21{
22 namespace cfg
23 {
24
25 // search for SPDLOG_LEVEL= in the args and use it to init the levels
26 inline void load_argv_levels(int argc, const char** argv)
27 {
28 const std::string spdlog_level_prefix = "SPDLOG_LEVEL=";
29 for (int i = 1; i < argc; i++)
30 {
31 std::string arg = argv[i];
32 if (arg.find(spdlog_level_prefix) == 0)
33 {
34 auto levels_string = arg.substr(spdlog_level_prefix.size());
35 helpers::load_levels(levels_string);
36 }
37 }
38 }
39
40 inline void load_argv_levels(int argc, char** argv)
41 {
42 load_argv_levels(argc, const_cast<const char**>(argv));
43 }
44
45 } // namespace cfg
46} // namespace spdlog
auto arg(const Char *name, const T &arg) -> detail::named_arg< Char, T >
Definition core.h:2506
SPDLOG_INLINE void load_levels(const std::string &input)
Definition helpers-inl.h:85
void load_argv_levels(int argc, const char **argv)
Definition argv.h:26
Definition async.h:26
i
Definition tag_strings.h:60