diff --git a/src/services.h b/src/services.h index 4b447983d..b16598180 100644 --- a/src/services.h +++ b/src/services.h @@ -708,6 +708,20 @@ namespace dd return pred_dto; } + /** Find a logger name that does not exist yet for chain call */ + std::string find_logger_name(std::string cname) + { + int i = 1; + std::string prefix = cname; + + while (spdlog::get(cname) != nullptr) + { + i++; + cname = prefix + "-" + std::to_string(i); + } + return cname; + } + int chain_service(const std::string &cname, const std::shared_ptr &chain_logger, APIData &adc, ChainData &cdata, @@ -914,12 +928,12 @@ namespace dd return 0; } - oatpp::Object chain(const APIData &ad, - const std::string &cname) + oatpp::Object chain(const APIData &ad, std::string cname) { oatpp::Object chain_dto; try { + cname = find_logger_name(cname); auto chain_logger = DD_SPDLOG_LOGGER(cname); std::chrono::time_point tstart @@ -1240,11 +1254,12 @@ namespace dd } oatpp::Object - chain(oatpp::Object input_dto, const std::string &cname) + chain(oatpp::Object input_dto, std::string cname) { oatpp::Object out_dto; try { + cname = find_logger_name(cname); auto chain_logger = DD_SPDLOG_LOGGER(cname); std::chrono::time_point tstart