refactor: use fmt (#2758)

* deps: use fmt (8.1.1 tag) to build log strings

Co-authored-by: Mike Gelfand <mikedld@mikedld.com>
This commit is contained in:
Charles Kerr
2022-03-13 23:43:35 -05:00
committed by GitHub
parent 2bd42f8225
commit a942c67199
44 changed files with 674 additions and 342 deletions

View File

@@ -2,6 +2,10 @@ project(trutils)
add_compile_options(${CXX_WARNING_FLAGS})
add_definitions(
${LIBFMT_DEFINITIONS}
)
include_directories(
${CMAKE_SOURCE_DIR}
)
@@ -9,6 +13,7 @@ include_directories(
SYSTEM
${EVENT2_INCLUDE_DIRS}
${CURL_INCLUDE_DIRS}
${LIBFMT_INCLUDE_DIRS}
)
foreach(P create edit remote show)

View File

@@ -14,10 +14,12 @@
#include <string>
#include <string_view>
#include <curl/curl.h>
#include <event2/buffer.h>
#include <event2/util.h>
#include <curl/curl.h>
#include <fmt/core.h>
#include <libtransmission/transmission.h>
#include <libtransmission/crypto-utils.h>
@@ -2000,7 +2002,7 @@ static int processResponse(char const* rpcurl, std::string_view response)
if (!tr_variantFromBuf(&top, TR_VARIANT_PARSE_JSON | TR_VARIANT_PARSE_INPLACE, response))
{
tr_logAddNamedWarn(MyName, "Unable to parse response \"%" TR_PRIsv "\"", TR_PRIsv_ARG(response));
tr_logAddNamedWarn(MyName, fmt::format("Unable to parse response '{}'", response));
status |= EXIT_FAILURE;
}
else
@@ -2172,7 +2174,7 @@ static int flush(char const* rpcurl, tr_variant** benc)
auto const res = curl_easy_perform(curl);
if (res != CURLE_OK)
{
tr_logAddNamedWarn(MyName, " (%s) %s", rpcurl_http.c_str(), curl_easy_strerror(res));
tr_logAddNamedWarn(MyName, fmt::format(" ({}) {}", rpcurl_http, curl_easy_strerror(res)));
status |= EXIT_FAILURE;
}
else