Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:24:42

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 {
0026     const std::string spdlog_level_prefix = "SPDLOG_LEVEL=";
0027     for (int i = 1; i < argc; i++)
0028     {
0029         std::string arg = argv[i];
0030         if (arg.find(spdlog_level_prefix) == 0)
0031         {
0032             auto levels_string = arg.substr(spdlog_level_prefix.size());
0033             helpers::load_levels(levels_string);
0034         }
0035     }
0036 }
0037 
0038 inline void load_argv_levels(int argc, char **argv)
0039 {
0040     load_argv_levels(argc, const_cast<const char **>(argv));
0041 }
0042 
0043 } // namespace cfg
0044 } // namespace spdlog