diff options
-rw-r--r-- | CMakeLists.txt | 7 | ||||
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | main.cpp | 19 | ||||
-rw-r--r-- | shared.h | 1 |
4 files changed, 18 insertions, 10 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b03a34..8cc6265 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,8 +61,11 @@ or /usr/local/lib") endif(NOT RESTBED_FOUND) +if(NOT TARGET spdlog) + find_package(spdlog REQUIRED) +endif() -add_executable(umosapi main.cpp config.cpp api/umosapi.cpp db/mongo_access.cpp db/uobject.cpp api/umosapi.h config.h db/mongo_access.h db/uobject.h shared.h) +add_executable(umosapi main.cpp config.cpp api/umosapi.cpp db/mongo_access.cpp db/uobject.cpp api/umosapi.h config.h db/mongo_access.h db/uobject.h shared.h logging.h) set_property(TARGET umosapi PROPERTY CXX_STANDARD 17) @@ -77,3 +80,5 @@ target_link_libraries(umosapi PUBLIC ${JSONC_LIBRARIES}) target_include_directories(umosapi PUBLIC ${RESTBED_INCLUDE_DIRS}) target_link_libraries(umosapi PUBLIC ${RESTBED_LIBRARIES}) + +target_link_libraries(umosapi PUBLIC spdlog::spdlog) @@ -21,6 +21,7 @@ Install: - json-c - nlohmann/json - mongocxx +- spdlog ### Why two json lib ? @@ -4,7 +4,9 @@ #include <pwd.h> #include "clara.hpp" + #include "shared.h" +#include "logging.h" #include "config.h" #include "api/umosapi.h" @@ -43,23 +45,22 @@ int main(int argc, char *argv[]) { exit(1); } - std::cout << "INFO: Using " << std::thread::hardware_concurrency() << " cores"; - std::cout << " - " << thr << " threads" << std::endl; - std::cout << "INFO: Listen on 0.0.0.0:" << config["port"] << std::endl; + spdlog::info("Using {} cores - {} threads", std::thread::hardware_concurrency(), thr); + spdlog::info("Listen on 0.0.0.0:{}", config["port"]); - std::cout << "INFO: Using config file '" << config_path << "'" << std::endl; + spdlog::info("Using config file '{}'", config_path); if (!std::filesystem::exists(config_path)) { - std::cout << "ERROR: Error fatal : config file '" << config_path << "' not found" << std::endl; - std::cout << "ERROR: config.txt is search here: ~/.config/umosapi/config.txt" << std::endl; + spdlog::error("Error fatal: config file '{}' not found", config_path); + spdlog::error("config.txt is searched here: ~/.config/umosapi.config.txt"); exit (EXIT_FAILURE); } load_config(config_path); - std::cout << "Using swaggerui " << config["swaggerui"] << " path" << std::endl; - std::cout << "INFO: No support for swagger for the moment" << std::endl; - std::cout << "INFO: Using mongoURI " << config["mongoURI"] << std::endl; + spdlog::info("Using swaggerui {} path", config["swaggerui"]); + spdlog::warn("No support for swagger for the moment"); + spdlog::info("Using mongoURI {}", config["mongoURI"]); UmosapiService::Api umosapi; umosapi.init(); @@ -2,6 +2,7 @@ #define SHARED_H_ #include <map> + #include "db/mongo_access.h" extern std::map<std::string, std::string> config; |