Agora
1.2.0
Agora project
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
5
#include <
spdlog/cfg/helpers.h
>
6
#include <
spdlog/details/registry.h
>
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
20
namespace
spdlog
{
21
namespace
cfg {
22
23
// search for SPDLOG_LEVEL= in the args and use it to init the levels
24
inline
void
load_argv_levels
(
int
argc,
const
char
**argv)
25
{
26
const
std::string spdlog_level_prefix =
"SPDLOG_LEVEL="
;
27
for
(
int
i
= 1;
i
< argc;
i
++)
28
{
29
std::string
arg
= argv[
i
];
30
if
(
arg
.find(spdlog_level_prefix) == 0)
31
{
32
auto
levels_string =
arg
.substr(spdlog_level_prefix.size());
33
helpers::load_levels
(levels_string);
34
}
35
}
36
}
37
38
inline
void
load_argv_levels
(
int
argc,
char
**argv)
39
{
40
load_argv_levels
(argc,
const_cast<
const
char
**
>
(argv));
41
}
42
43
}
// namespace cfg
44
}
// namespace spdlog
spdlog
Definition:
async.h:25
i
for i
Definition:
generate_data.m:107
helpers.h
fmt::v8::arg
auto arg(const Char *name, const T &arg) -> detail::named_arg< Char, T >
Definition:
core.h:1887
spdlog::cfg::load_argv_levels
void load_argv_levels(int argc, const char **argv)
Definition:
argv.h:24
registry.h
spdlog::cfg::helpers::load_levels
SPDLOG_INLINE void load_levels(const std::string &input)
Definition:
helpers-inl.h:82
third_party
spdlog
include
spdlog
cfg
argv.h
Generated by
1.8.17