diff --git a/CMakeLists.txt b/CMakeLists.txt index b5c351fc025a2a75bee0ecc1e452fe4dd41e2a29..118c19e2fb2f75268e7884b229694c9c4c011698 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,7 +84,7 @@ set(CMAKE_SHARED_LINKER_FLAGS_ASAN set_property(GLOBAL APPEND PROPERTY DEBUG_CONFIGURATIONS Debug) set_property(GLOBAL APPEND PROPERTY DEBUG_CONFIGURATIONS ASan) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) message(STATUS "[${PROJECT_NAME}] Project version: ${PROJECT_VERSION}") @@ -220,7 +220,7 @@ message(STATUS "[${PROJECT_NAME}] Downloading and building file_options") FetchContent_Declare( file_options GIT_REPOSITORY https://storage.bsc.es/gitlab/utils/file_options - GIT_TAG 50071ff78d0974b2f1178f27ce1a08d22e5e8fa2 # v0.1.0-pre + GIT_TAG bdb4f7f7f2dd731815241fc41afe6373df8f732a # v0.1.0-pre GIT_SHALLOW ON GIT_PROGRESS ON ) diff --git a/examples/cxx/common.cpp b/examples/cxx/common.cpp index be3585d92eb0da3812486c3f7f4936a561259164..31c57c679c2d7f45b62b8e006476ef0198e1d13f 100644 --- a/examples/cxx/common.cpp +++ b/examples/cxx/common.cpp @@ -16,7 +16,7 @@ prepare_datasets(const std::string& pattern, size_t n) { std::vector datasets; datasets.reserve(n); for(size_t i = 0; i < n; ++i) { - datasets.emplace_back(fmt::format(pattern, i)); + datasets.emplace_back(fmt::format(fmt::runtime(pattern), i)); } return datasets; diff --git a/src/common/logger/logger.hpp b/src/common/logger/logger.hpp index 7aa530cb8a06ab78c762a5c388e09b3d78b1174c..1dfa3d23877ec61b685d835ea9ad6e11e8629180 100644 --- a/src/common/logger/logger.hpp +++ b/src/common/logger/logger.hpp @@ -161,26 +161,26 @@ public: template inline void - info(const char* fmt, const Args&... args) { - m_internal_logger->info(fmt, args...); + info(fmt::format_string fmt, Args&&... args) { + m_internal_logger->info(fmt, std::forward(args)...); } template inline void - debug(const char* fmt, const Args&... args) { - m_internal_logger->debug(fmt, args...); + debug(fmt::format_string fmt, Args&&... args) { + m_internal_logger->debug(fmt, std::forward(args)...); } template inline void - warn(const char* fmt, const Args&... args) { - m_internal_logger->warn(fmt, args...); + warn(fmt::format_string fmt, Args&&... args) { + m_internal_logger->warn(fmt, std::forward(args)...); } template inline void - error(const char* fmt, const Args&... args) { - m_internal_logger->error(fmt, args...); + error(fmt::format_string fmt, Args&&... args) { + m_internal_logger->error(fmt, std::forward(args)...); } static inline std::string @@ -194,25 +194,27 @@ public: template inline void - error_errno(const char* fmt, const Args&... args) { + error_errno(fmt::format_string fmt, Args&&... args) { const int saved_errno = errno; constexpr const std::size_t MAX_ERROR_MSG = 128; - std::array errstr; + std::array errstr; // NOLINT - std::string str_fmt(fmt); + fmt::string_view sv{fmt}; + std::string str_fmt{sv.begin(), sv.end()}; str_fmt += ": {}"; char* msg = strerror_r(saved_errno, errstr.data(), MAX_ERROR_MSG); - m_internal_logger->error(str_fmt.c_str(), args..., msg); + m_internal_logger->error(fmt::runtime(str_fmt), + std::forward(args)..., msg); } template inline void - critical(const char* fmt, const Args&... args) { - m_internal_logger->critical(fmt, args...); + critical(fmt::format_string fmt, Args&&... args) { + m_internal_logger->critical(fmt, std::forward(args)...); } template diff --git a/src/common/net/server.cpp b/src/common/net/server.cpp index 22174f21e29239a38de3db88ea4662b50009a95f..992933717450312d198651cc4673717f1927134f 100644 --- a/src/common/net/server.cpp +++ b/src/common/net/server.cpp @@ -296,15 +296,12 @@ server::check_configuration() { void server::print_greeting() { - const char greeting[] = "Starting {} daemon (pid {})"; - const auto gsep = - std::string(sizeof(greeting) - 4 + m_settings->progname().size() + - std::to_string(getpid()).size(), - '='); - - LOGGER_INFO("{}", gsep); - LOGGER_INFO(greeting, m_settings->progname(), getpid()); - LOGGER_INFO("{}", gsep); + const auto greeting = fmt::format("Starting {} daemon (pid {})", + m_settings->progname(), getpid()); + + LOGGER_INFO("{:=>{}}", "", greeting.size()); + LOGGER_INFO(greeting); + LOGGER_INFO("{:=>{}}", "", greeting.size()); } void @@ -332,15 +329,12 @@ server::print_configuration() { void server::print_farewell() { - const char farewell[] = "Stopping {} daemon (pid {})"; - const auto fsep = - std::string(sizeof(farewell) - 4 + m_settings->progname().size() + - std::to_string(getpid()).size(), - '='); - - LOGGER_INFO("{}", fsep); - LOGGER_INFO(farewell, m_settings->progname(), getpid()); - LOGGER_INFO("{}", fsep); + const auto farewell = fmt::format("Stopping {} daemon (pid {})", + m_settings->progname(), getpid()); + + LOGGER_INFO("{:=>{}}", "", farewell.size()); + LOGGER_INFO(farewell); + LOGGER_INFO("{:=>{}}", "", farewell.size()); } int diff --git a/src/lib/detail/impl.cpp b/src/lib/detail/impl.cpp index 962f1f92ee8e6bcd3964ad245b3fd8672de773cd..bad2ab03dcdb2dc268711ad9dfd05a9a889a01ae 100644 --- a/src/lib/detail/impl.cpp +++ b/src/lib/detail/impl.cpp @@ -366,9 +366,9 @@ deploy_adhoc_storage(const server& srv, const adhoc_storage& adhoc_storage) { auto endp = rpc_client.lookup(srv.address()); LOGGER_INFO("rpc id: {} name: {} from: {} => " - "body: {{adhoc_storage: {}}}", + "body: {{adhoc_id: {}}}", rpc_id, std::quoted("ADM_"s + __FUNCTION__), - std::quoted(rpc_client.self_address()), adhoc_storage); + std::quoted(rpc_client.self_address()), adhoc_storage.id()); ADM_deploy_adhoc_storage_in_t in{adhoc_storage.id()}; ADM_deploy_adhoc_storage_out_t out; @@ -384,8 +384,9 @@ deploy_adhoc_storage(const server& srv, const adhoc_storage& adhoc_storage) { } LOGGER_INFO("rpc id: {} name: {} from: {} <= " - "body: {{retval: {}}}] [op_id: {}]", + "body: {{retval: {}}} [op_id: {}]", rpc_id, std::quoted("ADM_"s + __FUNCTION__), + std::quoted(rpc_client.self_address()), admire::error_code::success, out.op_id); return admire::error_code::success; diff --git a/src/scord/rpc_handlers.cpp b/src/scord/rpc_handlers.cpp index 2c5307429318c09c9beab2649ff2c9537ead3b16..190af86725204c76cb6cf0c047b0be797464369a 100644 --- a/src/scord/rpc_handlers.cpp +++ b/src/scord/rpc_handlers.cpp @@ -528,6 +528,7 @@ ADM_deploy_adhoc_storage(hg_handle_t h) { std::quoted(get_address(h)), ec); } + out.op_id = rpc_id; out.retval = ec; LOGGER_INFO("rpc id: {} name: {} to: {} <= " @@ -1081,7 +1082,7 @@ ADM_adhoc_access(hg_handle_t h) { if(in.access == nullptr) { LOGGER_ERROR("ADM_adhoc_access(): invalid access (nullptr)"); } else { - LOGGER_INFO("ADM_adhoc_access({}, {})", in.access); + LOGGER_INFO("ADM_adhoc_access({})", in.access); if((acc == "write-only") || (acc == "read-only") || (acc == "read-write")) {