Loading ifs/README.md +6 −0 Original line number Diff line number Diff line Loading @@ -145,3 +145,9 @@ an MPI application use the `{mpirun, mpiexec} -x` argument. Please consult `configure_public.hpp` for log locations and verbosity, etc. `include/configure.hpp` contains file system specific configurations normal user should not be needed to modify. ### Logging To enable logging the following environment variables are used: ADAFS_PRELOAD_LOG_PATH="<path/to/file>" to set the path to the logging file of the client library. ADAFS_DAEMON_LOG_PATH="<path/to/file>" to set the path to the logging file of the daemon. ADAFS_LOG_LEVEL={off,critical,err,warn,info,debug,trace} to set the trace level verbosity. Numbers from 0-6 may also be used where as 0 is off and 6 represents trace. No newline at end of file ifs/include/global/log_util.hpp +2 −2 Original line number Diff line number Diff line Loading @@ -4,8 +4,8 @@ #include <spdlog/spdlog.h> spdlog::level::level_enum get_spdlog_level(const std::string& level_str); spdlog::level::level_enum get_spdlog_level(unsigned int level); spdlog::level::level_enum get_spdlog_level(std::string level_str); spdlog::level::level_enum get_spdlog_level(unsigned long level); void setup_loggers(const std::vector<std::string>& loggers, spdlog::level::level_enum level, const std::string& path); Loading ifs/src/global/log_util.cpp +32 −14 Original line number Diff line number Diff line #include "global/log_util.hpp" #include <global/log_util.hpp> #include <spdlog/sinks/basic_file_sink.h> #include <exception> #include <vector> #include <list> #include <boost/algorithm/string.hpp> using namespace std; spdlog::level::level_enum get_spdlog_level(const std::string& level_str) { spdlog::level::level_enum get_spdlog_level(string level_str) { char* parse_end; unsigned long long uint_level = strtoul(level_str.c_str(), &parse_end, 10); auto level = strtoul(level_str.c_str(), &parse_end, 10); if (parse_end != (level_str.c_str() + level_str.size())) { throw std::runtime_error("Error: log level has wrong format: '" + level_str + "'"); } return get_spdlog_level(uint_level); // no conversion could be performed. Must be a string then boost::algorithm::to_lower(level_str); if (level_str == "off"s) return spdlog::level::off; else if (level_str == "critical"s) return spdlog::level::critical; else if (level_str == "err"s) return spdlog::level::err; else if (level_str == "warn"s) return spdlog::level::warn; else if (level_str == "info"s) return spdlog::level::info; else if (level_str == "debug"s) return spdlog::level::debug; else if (level_str == "trace"s) return spdlog::level::trace; else throw runtime_error(fmt::format("Error: log level '{}' is invalid. Check help/readme.", level_str)); } else return get_spdlog_level(level); } spdlog::level::level_enum get_spdlog_level(unsigned int level) { spdlog::level::level_enum get_spdlog_level(unsigned long level) { switch(level) { case 0: return spdlog::level::off; Loading @@ -34,16 +52,16 @@ spdlog::level::level_enum get_spdlog_level(unsigned int level) { } } void setup_loggers(const std::vector<std::string>& loggers_name, spdlog::level::level_enum level, const std::string& path) { void setup_loggers(const vector<string>& loggers_name, spdlog::level::level_enum level, const string& path) { /* Create common sink */ auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>(path); auto file_sink = make_shared<spdlog::sinks::basic_file_sink_mt>(path); /* Create and configure loggers */ auto loggers = std::list<std::shared_ptr<spdlog::logger>>(); auto loggers = list<shared_ptr<spdlog::logger>>(); for(const auto& name: loggers_name){ auto logger = std::make_shared<spdlog::logger>(name, file_sink); auto logger = make_shared<spdlog::logger>(name, file_sink); logger->flush_on(spdlog::level::trace); loggers.push_back(logger); } Loading Loading
ifs/README.md +6 −0 Original line number Diff line number Diff line Loading @@ -145,3 +145,9 @@ an MPI application use the `{mpirun, mpiexec} -x` argument. Please consult `configure_public.hpp` for log locations and verbosity, etc. `include/configure.hpp` contains file system specific configurations normal user should not be needed to modify. ### Logging To enable logging the following environment variables are used: ADAFS_PRELOAD_LOG_PATH="<path/to/file>" to set the path to the logging file of the client library. ADAFS_DAEMON_LOG_PATH="<path/to/file>" to set the path to the logging file of the daemon. ADAFS_LOG_LEVEL={off,critical,err,warn,info,debug,trace} to set the trace level verbosity. Numbers from 0-6 may also be used where as 0 is off and 6 represents trace. No newline at end of file
ifs/include/global/log_util.hpp +2 −2 Original line number Diff line number Diff line Loading @@ -4,8 +4,8 @@ #include <spdlog/spdlog.h> spdlog::level::level_enum get_spdlog_level(const std::string& level_str); spdlog::level::level_enum get_spdlog_level(unsigned int level); spdlog::level::level_enum get_spdlog_level(std::string level_str); spdlog::level::level_enum get_spdlog_level(unsigned long level); void setup_loggers(const std::vector<std::string>& loggers, spdlog::level::level_enum level, const std::string& path); Loading
ifs/src/global/log_util.cpp +32 −14 Original line number Diff line number Diff line #include "global/log_util.hpp" #include <global/log_util.hpp> #include <spdlog/sinks/basic_file_sink.h> #include <exception> #include <vector> #include <list> #include <boost/algorithm/string.hpp> using namespace std; spdlog::level::level_enum get_spdlog_level(const std::string& level_str) { spdlog::level::level_enum get_spdlog_level(string level_str) { char* parse_end; unsigned long long uint_level = strtoul(level_str.c_str(), &parse_end, 10); auto level = strtoul(level_str.c_str(), &parse_end, 10); if (parse_end != (level_str.c_str() + level_str.size())) { throw std::runtime_error("Error: log level has wrong format: '" + level_str + "'"); } return get_spdlog_level(uint_level); // no conversion could be performed. Must be a string then boost::algorithm::to_lower(level_str); if (level_str == "off"s) return spdlog::level::off; else if (level_str == "critical"s) return spdlog::level::critical; else if (level_str == "err"s) return spdlog::level::err; else if (level_str == "warn"s) return spdlog::level::warn; else if (level_str == "info"s) return spdlog::level::info; else if (level_str == "debug"s) return spdlog::level::debug; else if (level_str == "trace"s) return spdlog::level::trace; else throw runtime_error(fmt::format("Error: log level '{}' is invalid. Check help/readme.", level_str)); } else return get_spdlog_level(level); } spdlog::level::level_enum get_spdlog_level(unsigned int level) { spdlog::level::level_enum get_spdlog_level(unsigned long level) { switch(level) { case 0: return spdlog::level::off; Loading @@ -34,16 +52,16 @@ spdlog::level::level_enum get_spdlog_level(unsigned int level) { } } void setup_loggers(const std::vector<std::string>& loggers_name, spdlog::level::level_enum level, const std::string& path) { void setup_loggers(const vector<string>& loggers_name, spdlog::level::level_enum level, const string& path) { /* Create common sink */ auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>(path); auto file_sink = make_shared<spdlog::sinks::basic_file_sink_mt>(path); /* Create and configure loggers */ auto loggers = std::list<std::shared_ptr<spdlog::logger>>(); auto loggers = list<shared_ptr<spdlog::logger>>(); for(const auto& name: loggers_name){ auto logger = std::make_shared<spdlog::logger>(name, file_sink); auto logger = make_shared<spdlog::logger>(name, file_sink); logger->flush_on(spdlog::level::trace); loggers.push_back(logger); } Loading