Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-15 09:11:21

0001 // Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
0002 // Distributed under the MIT License (http://opensource.org/licenses/MIT)
0003 
0004 #pragma once
0005 #include <spdlog/cfg/helpers.h>
0006 #include <spdlog/details/registry.h>
0007 
0008 //
0009 // Init log levels using each argv entry that starts with "SPDLOG_LEVEL="
0010 //
0011 // set all loggers to debug level:
0012 // example.exe "SPDLOG_LEVEL=debug"
0013 
0014 // set logger1 to trace level
0015 // example.exe "SPDLOG_LEVEL=logger1=trace"
0016 
0017 // turn off all logging except for logger1 and logger2:
0018 // example.exe "SPDLOG_LEVEL=off,logger1=debug,logger2=info"
0019 
0020 namespace spdlog {
0021 namespace cfg {
0022 
0023 // search for SPDLOG_LEVEL= in the args and use it to init the levels
0024 inline void load_argv_levels(int argc, const char **argv) {
0025     const std::string spdlog_level_prefix = "SPDLOG_LEVEL=";
0026     for (int i = 1; i < argc; i++) {
0027         std::string arg = argv[i];
0028         if (arg.find(spdlog_level_prefix) == 0) {
0029             auto levels_string = arg.substr(spdlog_level_prefix.size());
0030             helpers::load_levels(levels_string);
0031         }
0032     }
0033 }
0034 
0035 inline void load_argv_levels(int argc, char **argv) {
0036     load_argv_levels(argc, const_cast<const char **>(argv));
0037 }
0038 
0039 }  // namespace cfg
0040 }  // namespace spdlog