Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gabime/spdlog.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgabime <gmelman1@gmail.com>2019-12-21 18:47:02 +0300
committergabime <gmelman1@gmail.com>2019-12-21 18:47:02 +0300
commit773b8c5a54317f18a60f2cb1c39257db548056c8 (patch)
tree7f99c15e00a2d4ec9915c876ab758aa606305109 /include/spdlog/cfg/argv.h
parentfc3d18ed64715b43a1cab919e59acc9f950fb06d (diff)
refectored file names
Diffstat (limited to 'include/spdlog/cfg/argv.h')
-rw-r--r--include/spdlog/cfg/argv.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/include/spdlog/cfg/argv.h b/include/spdlog/cfg/argv.h
new file mode 100644
index 00000000..b690032c
--- /dev/null
+++ b/include/spdlog/cfg/argv.h
@@ -0,0 +1,32 @@
+// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
+// Distributed under the MIT License (http://opensource.org/licenses/MIT)
+
+#pragma once
+#include <spdlog/cfg/helpers.h>
+#include <spdlog/details/os.h>
+
+//
+// Init levels from argv SPDLOG_LEVEL
+// Example: my_program.exe "SPDLOG_LEVEL=trace"
+
+namespace spdlog {
+namespace cfg {
+namespace argv {
+// search for SPDLOG_LEVEL= in the args and use it to init the levels
+void load_levels(int args, char *argv[])
+{
+ const std::string spdlog_level_prefix = "SPDLOG_LEVEL=";
+ for (int i = 1; i < args; i++)
+ {
+ std::string arg = argv[i];
+ if (arg.find(spdlog_level_prefix) == 0)
+ {
+ auto levels_string = arg.substr(spdlog_level_prefix.size());
+ auto levels = helpers::extract_levels(levels_string);
+ details::registry::instance().update_levels(std::move(levels));
+ }
+ }
+}
+} // namespace argv
+} // namespace cfg
+} // namespace spdlog