From d5b7c0d0b302fe6d09b5eb664453cf3aefc75e39 Mon Sep 17 00:00:00 2001 From: Dzmitry Neviadomski Date: Tue, 7 May 2024 15:42:23 +0300 Subject: [PATCH] fix: wrap runtime format strings with fmt::runtime in library, daemon and cli fmt::format_string ctor is consteval with C++20 See https://github.com/fmtlib/fmt/issues/2438 Signed-off-by: Dzmitry Neviadomski --- daemon/daemon.cc | 29 ++++++++++++----------- libtransmission/announcer-http.cc | 4 ++-- libtransmission/announcer-udp.cc | 9 +++---- libtransmission/announcer.cc | 13 ++++++---- libtransmission/blocklist.cc | 20 +++++++++------- libtransmission/crypto-utils-ccrypto.cc | 2 +- libtransmission/crypto-utils-mbedtls.cc | 2 +- libtransmission/crypto-utils-openssl.cc | 2 +- libtransmission/crypto-utils-wolfssl.cc | 2 +- libtransmission/inout.cc | 2 +- libtransmission/ip-cache.cc | 7 +++--- libtransmission/makemeta.cc | 2 +- libtransmission/net.cc | 15 ++++++------ libtransmission/open-files.cc | 8 +++---- libtransmission/peer-io.cc | 2 +- libtransmission/port-forwarding-natpmp.cc | 9 ++++--- libtransmission/port-forwarding-upnp.cc | 14 ++++++----- libtransmission/port-forwarding.cc | 4 ++-- libtransmission/rpc-server.cc | 27 ++++++++++++--------- libtransmission/rpcimpl.cc | 8 +++---- libtransmission/session-id.cc | 4 ++-- libtransmission/session.cc | 10 ++++---- libtransmission/torrent-metainfo.cc | 2 +- libtransmission/torrent.cc | 16 ++++++------- libtransmission/tr-dht.cc | 4 ++-- libtransmission/tr-lpd.cc | 4 ++-- libtransmission/tr-udp.cc | 8 +++---- libtransmission/utils.cc | 10 ++++---- libtransmission/variant-json.cc | 2 +- libtransmission/variant.cc | 2 +- libtransmission/watchdir-inotify.cc | 14 +++++------ libtransmission/watchdir.cc | 6 ++--- libtransmission/web.cc | 7 +++--- tests/libtransmission/dht-test.cc | 2 +- utils/create.cc | 7 +++--- utils/remote.cc | 2 +- 36 files changed, 152 insertions(+), 129 deletions(-) diff --git a/daemon/daemon.cc b/daemon/daemon.cc index 7b0e0203222..32443d435b3 100644 --- a/daemon/daemon.cc +++ b/daemon/daemon.cc @@ -194,7 +194,7 @@ auto onFileAdded(tr_session* session, std::string_view dirname, std::string_view if (!tr_file_read(filename, content, &error)) { tr_logAddWarn(fmt::format( - _("Couldn't read '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't read '{path}': {error} ({error_code})")), fmt::arg("path", basename), fmt::arg("error", error.message()), fmt::arg("error_code", error.code()))); @@ -219,7 +219,7 @@ auto onFileAdded(tr_session* session, std::string_view dirname, std::string_view if (tr_torrentNew(ctor, nullptr) == nullptr) { - tr_logAddError(fmt::format(_("Couldn't add torrent file '{path}'"), fmt::arg("path", basename))); + tr_logAddError(fmt::format(fmt::runtime(_("Couldn't add torrent file '{path}'")), fmt::arg("path", basename))); } else { @@ -228,12 +228,12 @@ auto onFileAdded(tr_session* session, std::string_view dirname, std::string_view if (test && trash) { - tr_logAddInfo(fmt::format(_("Removing torrent file '{path}'"), fmt::arg("path", basename))); + tr_logAddInfo(fmt::format(fmt::runtime(_("Removing torrent file '{path}'")), fmt::arg("path", basename))); if (auto error = tr_error{}; !tr_sys_path_remove(filename, &error)) { tr_logAddError(fmt::format( - _("Couldn't remove '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't remove '{path}': {error} ({error_code})")), fmt::arg("path", basename), fmt::arg("error", error.message()), fmt::arg("error_code", error.code()))); @@ -633,7 +633,8 @@ bool tr_daemon::parse_args(int argc, char const* const* argv, bool* dump_setting } else { - std::cerr << fmt::format(_("Couldn't parse log level '{level}'"), fmt::arg("level", optstr)) << std::endl; + std::cerr << fmt::format(fmt::runtime(_("Couldn't parse log level '{level}'")), fmt::arg("level", optstr)) + << std::endl; } break; @@ -694,7 +695,7 @@ void tr_daemon::reconfigure() } configDir = tr_sessionGetConfigDir(my_session_); - tr_logAddInfo(fmt::format(_("Reloading settings from '{path}'"), fmt::arg("path", configDir))); + tr_logAddInfo(fmt::format(fmt::runtime(_("Reloading settings from '{path}'")), fmt::arg("path", configDir))); tr_sessionSet(my_session_, load_settings(configDir)); tr_sessionReloadBlocklists(my_session_); @@ -718,7 +719,7 @@ int tr_daemon::start([[maybe_unused]] bool foreground) { auto const error_code = errno; auto const errmsg = fmt::format( - _("Couldn't initialize daemon: {error} ({error_code})"), + fmt::runtime(_("Couldn't initialize daemon: {error} ({error_code})")), fmt::arg("error", tr_strerror(error_code)), fmt::arg("error_code", error_code)); printMessage(log_stream_, TR_LOG_ERROR, MyName, errmsg, __FILE__, __LINE__); @@ -730,7 +731,7 @@ int tr_daemon::start([[maybe_unused]] bool foreground) auto const* const cdir = this->config_dir_.c_str(); auto* session = tr_sessionInit(cdir, true, settings_); tr_sessionSetRPCCallback(session, on_rpc_callback, this); - tr_logAddInfo(fmt::format(_("Loading settings from '{path}'"), fmt::arg("path", cdir))); + tr_logAddInfo(fmt::format(fmt::runtime(_("Loading settings from '{path}'")), fmt::arg("path", cdir))); tr_sessionSaveSettings(session, cdir, settings_); auto sv = std::string_view{}; @@ -751,13 +752,13 @@ int tr_daemon::start([[maybe_unused]] bool foreground) auto const out = std::to_string(getpid()); tr_sys_file_write(fp, std::data(out), std::size(out), nullptr); tr_sys_file_close(fp); - tr_logAddInfo(fmt::format(_("Saved pidfile '{path}'"), fmt::arg("path", sz_pid_filename))); + tr_logAddInfo(fmt::format(fmt::runtime(_("Saved pidfile '{path}'")), fmt::arg("path", sz_pid_filename))); pidfile_created = true; } else { tr_logAddError(fmt::format( - _("Couldn't save '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't save '{path}': {error} ({error_code})")), fmt::arg("path", sz_pid_filename), fmt::arg("error", error.message()), fmt::arg("error_code", error.code()))); @@ -788,7 +789,7 @@ int tr_daemon::start([[maybe_unused]] bool foreground) (void)tr_variantDictFindStrView(&settings_, TR_KEY_watch_dir, &dir); if (!std::empty(dir)) { - tr_logAddInfo(fmt::format(_("Watching '{path}' for new torrent files"), fmt::arg("path", dir))); + tr_logAddInfo(fmt::format(fmt::runtime(_("Watching '{path}' for new torrent files")), fmt::arg("path", dir))); auto handler = [session](std::string_view dirname, std::string_view basename) { @@ -833,7 +834,7 @@ int tr_daemon::start([[maybe_unused]] bool foreground) { auto const error_code = errno; tr_logAddError(fmt::format( - _("Couldn't create event: {error} ({error_code})"), + fmt::runtime(_("Couldn't create event: {error} ({error_code})")), fmt::arg("error", tr_strerror(error_code)), fmt::arg("error_code", error_code))); goto CLEANUP; @@ -843,7 +844,7 @@ int tr_daemon::start([[maybe_unused]] bool foreground) { auto const error_code = errno; tr_logAddError(fmt::format( - _("Couldn't add event: {error} ({error_code})"), + fmt::runtime(_("Couldn't add event: {error} ({error_code})")), fmt::arg("error", tr_strerror(error_code)), fmt::arg("error_code", error_code))); goto CLEANUP; @@ -857,7 +858,7 @@ int tr_daemon::start([[maybe_unused]] bool foreground) { auto const error_code = errno; tr_logAddError(fmt::format( - _("Couldn't launch daemon event loop: {error} ({error_code})"), + fmt::runtime(_("Couldn't launch daemon event loop: {error} ({error_code})")), fmt::arg("error", tr_strerror(error_code)), fmt::arg("error_code", error_code))); goto CLEANUP; diff --git a/libtransmission/announcer-http.cc b/libtransmission/announcer-http.cc index 4a231e64cea..4ab4cc4ce45 100644 --- a/libtransmission/announcer-http.cc +++ b/libtransmission/announcer-http.cc @@ -433,7 +433,7 @@ void tr_announcerParseHttpAnnounceResponse(tr_announce_response& response, std:: { tr_logAddWarn( fmt::format( - _("Couldn't parse announce response: {error} ({error_code})"), + fmt::runtime(_("Couldn't parse announce response: {error} ({error_code})")), fmt::arg("error", error.message()), fmt::arg("error_code", error.code())), log_name); @@ -640,7 +640,7 @@ void tr_announcerParseHttpScrapeResponse(tr_scrape_response& response, std::stri { tr_logAddWarn( fmt::format( - _("Couldn't parse scrape response: {error} ({error_code})"), + fmt::runtime(_("Couldn't parse scrape response: {error} ({error_code})")), fmt::arg("error", error.message()), fmt::arg("error_code", error.code())), log_name); diff --git a/libtransmission/announcer-udp.cc b/libtransmission/announcer-udp.cc index f2f03d76c15..0bc346075ea 100644 --- a/libtransmission/announcer-udp.cc +++ b/libtransmission/announcer-udp.cc @@ -370,9 +370,10 @@ struct tau_tracker } else if (action == TAU_ACTION_ERROR) { - std::string errmsg = !std::empty(buf) ? - buf.to_string() : - fmt::format(_("{ip_protocol} connection failed"), fmt::arg("ip_protocol", tr_ip_protocol_to_sv(ip_protocol))); + std::string errmsg = !std::empty(buf) ? buf.to_string() : + fmt::format( + fmt::runtime(_("{ip_protocol} connection failed")), + fmt::arg("ip_protocol", tr_ip_protocol_to_sv(ip_protocol))); fail_all(true, false, errmsg); logdbg(log_name(), std::move(errmsg)); } @@ -504,7 +505,7 @@ struct tau_tracker logwarn( log_name(), fmt::format( - _("Couldn't look up '{address}:{port}' in {ip_protocol}: {error} ({error_code})"), + fmt::runtime(_("Couldn't look up '{address}:{port}' in {ip_protocol}: {error} ({error_code})")), fmt::arg("address", host), fmt::arg("port", port.host()), fmt::arg("ip_protocol", tr_ip_protocol_to_sv(ip_protocol)), diff --git a/libtransmission/announcer.cc b/libtransmission/announcer.cc index 6e40995b550..4a037b87465 100644 --- a/libtransmission/announcer.cc +++ b/libtransmission/announcer.cc @@ -179,7 +179,7 @@ class tr_announcer_impl final : public tr_announcer } else { - tr_logAddError(fmt::format(_("Unsupported URL: '{url}'"), fmt::arg("url", scrape_sv))); + tr_logAddError(fmt::format(fmt::runtime(_("Unsupported URL: '{url}'")), fmt::arg("url", scrape_sv))); } } @@ -198,7 +198,7 @@ class tr_announcer_impl final : public tr_announcer } else { - tr_logAddWarn(fmt::format(_("Unsupported URL: '{url}'"), fmt::arg("url", announce_sv))); + tr_logAddWarn(fmt::format(fmt::runtime(_("Unsupported URL: '{url}'")), fmt::arg("url", announce_sv))); } } @@ -890,7 +890,10 @@ void on_announce_error(tr_tier* tier, char const* err, tr_announce_event e) { tr_logAddErrorTier( tier, - fmt::format(_("Announce error: {error} ({url})"), fmt::arg("error", err), fmt::arg("url", announce_url))); + fmt::format( + fmt::runtime(_("Announce error: {error} ({url})")), + fmt::arg("error", err), + fmt::arg("url", announce_url))); } else { @@ -899,10 +902,10 @@ void on_announce_error(tr_tier* tier, char const* err, tr_announce_event e) tr_logAddWarnTier( tier, fmt::format( - tr_ngettext( + fmt::runtime(tr_ngettext( "Announce error: {error} (Retrying in {count} second) ({url})", "Announce error: {error} (Retrying in {count} seconds) ({url})", - interval), + interval)), fmt::arg("error", err), fmt::arg("count", interval), fmt::arg("url", announce_url))); diff --git a/libtransmission/blocklist.cc b/libtransmission/blocklist.cc index 9ae103efe2c..e1bf5a0b899 100644 --- a/libtransmission/blocklist.cc +++ b/libtransmission/blocklist.cc @@ -59,7 +59,7 @@ void save(std::string_view filename, address_range_t const* ranges, size_t n_ran if (!out.is_open()) { tr_logAddWarn(fmt::format( - _("Couldn't read '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't read '{path}': {error} ({error_code})")), fmt::arg("path", filename), fmt::arg("error", tr_strerror(errno)), fmt::arg("error_code", errno))); @@ -70,7 +70,7 @@ void save(std::string_view filename, address_range_t const* ranges, size_t n_ran !out.write(reinterpret_cast(ranges), n_ranges * sizeof(*ranges))) { tr_logAddWarn(fmt::format( - _("Couldn't save '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't save '{path}': {error} ({error_code})")), fmt::arg("path", filename), fmt::arg("error", tr_strerror(errno)), fmt::arg("error_code", errno))); @@ -78,7 +78,8 @@ void save(std::string_view filename, address_range_t const* ranges, size_t n_ran else { tr_logAddInfo(fmt::format( - tr_ngettext("Blocklist '{path}' has {count} entry", "Blocklist '{path}' has {count} entries", n_ranges), + fmt::runtime( + tr_ngettext("Blocklist '{path}' has {count} entry", "Blocklist '{path}' has {count} entries", n_ranges)), fmt::arg("path", tr_sys_path_basename(filename)), fmt::arg("count", n_ranges))); } @@ -237,7 +238,7 @@ auto parseFile(std::string_view filename) if (!in.is_open()) { tr_logAddWarn(fmt::format( - _("Couldn't read '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't read '{path}': {error} ({error_code})")), fmt::arg("path", filename), fmt::arg("error", tr_strerror(errno)), fmt::arg("error_code", errno))); @@ -256,7 +257,7 @@ auto parseFile(std::string_view filename) else { // don't try to display the actual lines - it causes issues - tr_logAddWarn(fmt::format(_("Couldn't parse line: '{line}'"), fmt::arg("line", line_number))); + tr_logAddWarn(fmt::format(fmt::runtime(_("Couldn't parse line: '{line}'")), fmt::arg("line", line_number))); } } in.close(); @@ -335,7 +336,7 @@ void Blocklists::Blocklist::ensureLoaded() const if (error) { tr_logAddWarn(fmt::format( - _("Couldn't read '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't read '{path}': {error} ({error_code})")), fmt::arg("path", bin_file_), fmt::arg("error", error.message()), fmt::arg("error_code", error.code()))); @@ -350,7 +351,7 @@ void Blocklists::Blocklist::ensureLoaded() const if (!in) { tr_logAddWarn(fmt::format( - _("Couldn't read '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't read '{path}': {error} ({error_code})")), fmt::arg("path", bin_file_), fmt::arg("error", tr_strerror(errno)), fmt::arg("error_code", errno))); @@ -400,7 +401,8 @@ void Blocklists::Blocklist::ensureLoaded() const } tr_logAddInfo(fmt::format( - tr_ngettext("Blocklist '{path}' has {count} entry", "Blocklist '{path}' has {count} entries", std::size(rules_)), + fmt::runtime( + tr_ngettext("Blocklist '{path}' has {count} entry", "Blocklist '{path}' has {count} entries", std::size(rules_))), fmt::arg("path", tr_sys_path_basename(bin_file_)), fmt::arg("count", std::size(rules_)))); } @@ -470,7 +472,7 @@ std::optional Blocklists::Blocklist::saveNew( if (error) { tr_logAddWarn(fmt::format( - _("Couldn't save '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't save '{path}': {error} ({error_code})")), fmt::arg("path", src_file), fmt::arg("error", error.message()), fmt::arg("error_code", error.code()))); diff --git a/libtransmission/crypto-utils-ccrypto.cc b/libtransmission/crypto-utils-ccrypto.cc index ea05781a770..79864309c88 100644 --- a/libtransmission/crypto-utils-ccrypto.cc +++ b/libtransmission/crypto-utils-ccrypto.cc @@ -70,7 +70,7 @@ void log_ccrypto_error(CCCryptorStatus error_code, char const* file, long line) line, TR_LOG_ERROR, fmt::format( - _("{crypto_library} error: {error} ({error_code})"), + fmt::runtime(_("{crypto_library} error: {error} ({error_code})")), fmt::arg("crypto_library", "CCrypto"), fmt::arg("error", ccrypto_error_to_str(error_code)), fmt::arg("error_code", error_code))); diff --git a/libtransmission/crypto-utils-mbedtls.cc b/libtransmission/crypto-utils-mbedtls.cc index fad55b40d03..41fe277d571 100644 --- a/libtransmission/crypto-utils-mbedtls.cc +++ b/libtransmission/crypto-utils-mbedtls.cc @@ -42,7 +42,7 @@ void log_mbedtls_error(int error_code, char const* file, int line) line, TR_LOG_ERROR, fmt::format( - _("{crypto_library} error: {error} ({error_code})"), + fmt::runtime(_("{crypto_library} error: {error} ({error_code})")), fmt::arg("crypto_library", "MbedTLS"), fmt::arg("error", error_message), fmt::arg("error_code", error_code))); diff --git a/libtransmission/crypto-utils-openssl.cc b/libtransmission/crypto-utils-openssl.cc index 03a3106d604..3f0fe26ce85 100644 --- a/libtransmission/crypto-utils-openssl.cc +++ b/libtransmission/crypto-utils-openssl.cc @@ -61,7 +61,7 @@ void log_openssl_error(char const* file, int line) line, TR_LOG_ERROR, fmt::format( - _("{crypto_library} error: {error} ({error_code})"), + fmt::runtime(_("{crypto_library} error: {error} ({error_code})")), fmt::arg("crypto_library", "OpenSSL"), fmt::arg("error", std::data(buf)), fmt::arg("error_code", error_code))); diff --git a/libtransmission/crypto-utils-wolfssl.cc b/libtransmission/crypto-utils-wolfssl.cc index 0438974ef57..78c5e423215 100644 --- a/libtransmission/crypto-utils-wolfssl.cc +++ b/libtransmission/crypto-utils-wolfssl.cc @@ -45,7 +45,7 @@ void log_wolfssl_error(int error_code, char const* file, int line) line, TR_LOG_ERROR, fmt::format( - _("{crypto_library} error: {error} ({error_code})"), + fmt::runtime(_("{crypto_library} error: {error} ({error_code})")), fmt::arg("crypto_library", "WolfSSL"), fmt::arg("error", wc_GetErrorString(error_code)), fmt::arg("error_code", error_code))); diff --git a/libtransmission/inout.cc b/libtransmission/inout.cc index 604a9251e47..ed61774e67a 100644 --- a/libtransmission/inout.cc +++ b/libtransmission/inout.cc @@ -115,7 +115,7 @@ bool write_entire_buf(tr_sys_file_t const fd, uint64_t file_offset, uint8_t cons error.set( err, fmt::format( - _("Couldn't get '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't get '{path}': {error} ({error_code})")), fmt::arg("path", tor.file_subpath(file_index)), fmt::arg("error", tr_strerror(err)), fmt::arg("error_code", err))); diff --git a/libtransmission/ip-cache.cc b/libtransmission/ip-cache.cc index d5abe8ebec3..feb90c314b3 100644 --- a/libtransmission/ip-cache.cc +++ b/libtransmission/ip-cache.cc @@ -271,7 +271,7 @@ void tr_ip_cache::update_source_addr(tr_address_type type) noexcept { set_source_addr(*source_addr); tr_logAddDebug(fmt::format( - _("Successfully updated source {protocol} address to {ip}"), + fmt::runtime(_("Successfully updated source {protocol} address to {ip}")), fmt::arg("protocol", protocol), fmt::arg("ip", source_addr->display_name()))); } @@ -285,7 +285,8 @@ void tr_ip_cache::update_source_addr(tr_address_type type) noexcept { stop_timer(type); // No point in retrying has_ip_protocol = false; - tr_logAddInfo(fmt::format(_("Your machine does not support {protocol}"), fmt::arg("protocol", protocol))); + tr_logAddInfo( + fmt::format(fmt::runtime(_("Your machine does not support {protocol}")), fmt::arg("protocol", protocol))); } } @@ -310,7 +311,7 @@ void tr_ip_cache::on_response_ip_query(tr_address_type type, tr_web::FetchRespon upkeep_timers_[type]->set_interval(UpkeepInterval); tr_logAddDebug(fmt::format( - _("Successfully updated global {type} address to {ip} using {url}"), + fmt::runtime(_("Successfully updated global {type} address to {ip} using {url}")), fmt::arg("type", protocol), fmt::arg("ip", addr->display_name()), fmt::arg("url", IPQueryServices[type][ix_service]))); diff --git a/libtransmission/makemeta.cc b/libtransmission/makemeta.cc index 33ffae0478c..6e398c4aaac 100644 --- a/libtransmission/makemeta.cc +++ b/libtransmission/makemeta.cc @@ -77,7 +77,7 @@ void walkTree(std::string_view const top, std::string_view const subpath, std::s if (error) { tr_logAddWarn(fmt::format( - _("Skipping '{path}': {error} ({error_code})"), + fmt::runtime(_("Skipping '{path}': {error} ({error_code})")), fmt::arg("path", path), fmt::arg("error", error.message()), fmt::arg("error_code", error.code()))); diff --git a/libtransmission/net.cc b/libtransmission/net.cc index 576cf217596..906a97df774 100644 --- a/libtransmission/net.cc +++ b/libtransmission/net.cc @@ -189,7 +189,7 @@ tr_socket_t createSocket(int domain, int type) if (sockerrno != EAFNOSUPPORT) { tr_logAddWarn(fmt::format( - _("Couldn't create socket: {error} ({error_code})"), + fmt::runtime(_("Couldn't create socket: {error} ({error_code})")), fmt::arg("error", tr_net_strerror(sockerrno)), fmt::arg("error_code", sockerrno))); } @@ -266,7 +266,7 @@ tr_peer_socket tr_netOpenPeerSocket(tr_session* session, tr_socket_address const if (bind(s, reinterpret_cast(&source_sock), sourcelen) == -1) { tr_logAddWarn(fmt::format( - _("Couldn't set source address {address} on {socket}: {error} ({error_code})"), + fmt::runtime(_("Couldn't set source address {address} on {socket}: {error} ({error_code})")), fmt::arg("address", source_addr.display_name()), fmt::arg("socket", s), fmt::arg("error", tr_net_strerror(sockerrno)), @@ -285,7 +285,7 @@ tr_peer_socket tr_netOpenPeerSocket(tr_session* session, tr_socket_address const (tmperrno != ECONNREFUSED && tmperrno != ENETUNREACH && tmperrno != EHOSTUNREACH) || addr.is_ipv4()) { tr_logAddWarn(fmt::format( - _("Couldn't connect socket {socket} to {address}:{port}: {error} ({error_code})"), + fmt::runtime(_("Couldn't connect socket {socket} to {address}:{port}: {error} ({error_code})")), fmt::arg("socket", s), fmt::arg("address", addr.display_name()), fmt::arg("port", port.host()), @@ -343,9 +343,10 @@ tr_socket_t tr_netBindTCPImpl(tr_address const& addr, tr_port port, bool suppres if (!suppress_msgs) { tr_logAddError(fmt::format( - err == EADDRINUSE ? - _("Couldn't bind port {port} on {address}: {error} ({error_code}) -- Is another copy of Transmission already running?") : - _("Couldn't bind port {port} on {address}: {error} ({error_code})"), + fmt::runtime( + err == EADDRINUSE ? + _("Couldn't bind port {port} on {address}: {error} ({error_code}) -- Is another copy of Transmission already running?") : + _("Couldn't bind port {port} on {address}: {error} ({error_code})")), fmt::arg("address", addr.display_name()), fmt::arg("port", port.host()), fmt::arg("error", tr_net_strerror(err)), @@ -798,7 +799,7 @@ int tr_address::compare(tr_address const& that) const noexcept // <=> std::string tr_socket_address::display_name(tr_address const& address, tr_port port) noexcept { - return fmt::format(address.is_ipv6() ? "[{:s}]:{:d}" : "{:s}:{:d}", address.display_name(), port.host()); + return fmt::format(fmt::runtime(address.is_ipv6() ? "[{:s}]:{:d}" : "{:s}:{:d}"), address.display_name(), port.host()); } bool tr_socket_address::is_valid_for_peers(tr_peer_from from) const noexcept diff --git a/libtransmission/open-files.cc b/libtransmission/open-files.cc index 429eb40bfbc..749cdc14765 100644 --- a/libtransmission/open-files.cc +++ b/libtransmission/open-files.cc @@ -167,7 +167,7 @@ std::optional tr_open_files::get( if (!tr_sys_dir_create(dir, TR_SYS_DIR_CREATE_PARENTS, 0777, &error)) { tr_logAddError(fmt::format( - _("Couldn't create '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't create '{path}': {error} ({error_code})")), fmt::arg("path", dir), fmt::arg("error", error.message()), fmt::arg("error_code", error.code()))); @@ -189,7 +189,7 @@ std::optional tr_open_files::get( if (!is_open(fd)) { tr_logAddError(fmt::format( - _("Couldn't open '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't open '{path}': {error} ({error_code})")), fmt::arg("path", filename), fmt::arg("error", error.message()), fmt::arg("error_code", error.code()))); @@ -217,7 +217,7 @@ std::optional tr_open_files::get( if (!success) { tr_logAddError(fmt::format( - _("Couldn't preallocate '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't preallocate '{path}': {error} ({error_code})")), fmt::arg("path", filename), fmt::arg("error", error.message()), fmt::arg("error_code", error.code()))); @@ -236,7 +236,7 @@ std::optional tr_open_files::get( if (resize_needed && !tr_sys_file_truncate(fd, file_size, &error)) { tr_logAddWarn(fmt::format( - _("Couldn't truncate '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't truncate '{path}': {error} ({error_code})")), fmt::arg("path", filename), fmt::arg("error", error.message()), fmt::arg("error_code", error.code()))); diff --git a/libtransmission/peer-io.cc b/libtransmission/peer-io.cc index 2f7c1847dd4..c07c60142df 100644 --- a/libtransmission/peer-io.cc +++ b/libtransmission/peer-io.cc @@ -674,7 +674,7 @@ void tr_peerIo::on_utp_state_change(int state) } else { - tr_logAddErrorIo(this, fmt::format(_("Unknown state: {state}"), fmt::arg("state", state))); + tr_logAddErrorIo(this, fmt::format(fmt::runtime(_("Unknown state: {state}")), fmt::arg("state", state))); } } diff --git a/libtransmission/port-forwarding-natpmp.cc b/libtransmission/port-forwarding-natpmp.cc index 7d4d0054c45..b268c9dc23b 100644 --- a/libtransmission/port-forwarding-natpmp.cc +++ b/libtransmission/port-forwarding-natpmp.cc @@ -87,7 +87,8 @@ tr_natpmp::PulseResult tr_natpmp::pulse(tr_port local_port, bool is_enabled) { auto str = std::array{}; evutil_inet_ntop(AF_INET, &response.pnu.publicaddress.addr, std::data(str), std::size(str)); - tr_logAddInfo(fmt::format(_("Found public address '{address}'"), fmt::arg("address", std::data(str)))); + tr_logAddInfo( + fmt::format(fmt::runtime(_("Found public address '{address}'")), fmt::arg("address", std::data(str)))); state_ = State::Idle; } else if (val != NATPMP_TRYAGAIN) @@ -124,7 +125,8 @@ tr_natpmp::PulseResult tr_natpmp::pulse(tr_port local_port, bool is_enabled) { auto const unmapped_port = tr_port::from_host(resp.pnu.newportmapping.privateport); - tr_logAddInfo(fmt::format(_("Port {port} is no longer forwarded"), fmt::arg("port", unmapped_port.host()))); + tr_logAddInfo( + fmt::format(fmt::runtime(_("Port {port} is no longer forwarded")), fmt::arg("port", unmapped_port.host()))); if (local_port_ == unmapped_port) { @@ -172,7 +174,8 @@ tr_natpmp::PulseResult tr_natpmp::pulse(tr_port local_port, bool is_enabled) renew_time_ = tr_time() + (resp.pnu.newportmapping.lifetime / 2); local_port_ = tr_port::from_host(resp.pnu.newportmapping.privateport); advertised_port_ = tr_port::from_host(resp.pnu.newportmapping.mappedpublicport); - tr_logAddInfo(fmt::format(_("Port {port} forwarded successfully"), fmt::arg("port", local_port_.host()))); + tr_logAddInfo( + fmt::format(fmt::runtime(_("Port {port} forwarded successfully")), fmt::arg("port", local_port_.host()))); } else if (val != NATPMP_TRYAGAIN) { diff --git a/libtransmission/port-forwarding-upnp.cc b/libtransmission/port-forwarding-upnp.cc index a4146e0df13..d1d4c3aa520 100644 --- a/libtransmission/port-forwarding-upnp.cc +++ b/libtransmission/port-forwarding-upnp.cc @@ -269,8 +269,10 @@ tr_port_forwarding_state tr_upnpPulse( #endif == UPNP_IGD_VALID_CONNECTED) { - tr_logAddInfo(fmt::format(_("Found Internet Gateway Device '{url}'"), fmt::arg("url", handle->urls.controlURL))); - tr_logAddInfo(fmt::format(_("Local Address is '{address}'"), fmt::arg("address", lanaddr.data()))); + tr_logAddInfo(fmt::format( + fmt::runtime(_("Found Internet Gateway Device '{url}'")), + fmt::arg("url", handle->urls.controlURL))); + tr_logAddInfo(fmt::format(fmt::runtime(_("Local Address is '{address}'")), fmt::arg("address", lanaddr.data()))); handle->state = UpnpState::Idle; handle->lanaddr = std::data(lanaddr); } @@ -295,7 +297,7 @@ tr_port_forwarding_state tr_upnpPulse( get_specific_port_mapping_entry(handle, "UDP") != UPNPCOMMAND_SUCCESS)) { tr_logAddInfo(fmt::format( - _("Local port {local_port} is not forwarded to {advertised_port}"), + fmt::runtime(_("Local port {local_port} is not forwarded to {advertised_port}")), fmt::arg("local_port", handle->local_port.host()), fmt::arg("advertised_port", handle->advertised_port.host()))); handle->isMapped = false; @@ -307,7 +309,7 @@ tr_port_forwarding_state tr_upnpPulse( tr_upnpDeletePortMapping(handle, "UDP", handle->advertised_port); tr_logAddInfo(fmt::format( - _("Stopping port forwarding through '{url}', service '{type}'"), + fmt::runtime(_("Stopping port forwarding through '{url}', service '{type}'")), fmt::arg("url", handle->urls.controlURL), fmt::arg("type", handle->data.first.servicetype))); @@ -340,7 +342,7 @@ tr_port_forwarding_state tr_upnpPulse( } tr_logAddDebug(fmt::format( - _("Port forwarding through '{url}', service '{type}'. (local address: {address}:{port})"), + fmt::runtime(_("Port forwarding through '{url}', service '{type}'. (local address: {address}:{port})")), fmt::arg("url", handle->urls.controlURL), fmt::arg("type", handle->data.first.servicetype), fmt::arg("address", handle->lanaddr), @@ -349,7 +351,7 @@ tr_port_forwarding_state tr_upnpPulse( if (handle->isMapped) { tr_logAddInfo(fmt::format( - _("Forwarded local port {local_port} to {advertised_port}"), + fmt::runtime(_("Forwarded local port {local_port} to {advertised_port}")), fmt::arg("local_port", local_port.host()), fmt::arg("advertised_port", advertised_port.host()))); handle->advertised_port = advertised_port; diff --git a/libtransmission/port-forwarding.cc b/libtransmission/port-forwarding.cc index 4161c0850f1..e9129f6b8d3 100644 --- a/libtransmission/port-forwarding.cc +++ b/libtransmission/port-forwarding.cc @@ -198,7 +198,7 @@ class tr_port_forwarding_impl final : public tr_port_forwarding { mediator_.on_port_forwarded(result.advertised_port); tr_logAddInfo(fmt::format( - _("Mapped private port {private_port} to public port {public_port}"), + fmt::runtime(_("Mapped private port {private_port} to public port {public_port}")), fmt::arg("private_port", result.local_port.host()), fmt::arg("public_port", result.advertised_port.host()))); } @@ -214,7 +214,7 @@ class tr_port_forwarding_impl final : public tr_port_forwarding if (auto const new_state = state(); new_state != old_state) { tr_logAddInfo(fmt::format( - _("State changed from '{old_state}' to '{state}'"), + fmt::runtime(_("State changed from '{old_state}' to '{state}'")), fmt::arg("old_state", getNatStateStr(old_state)), fmt::arg("state", getNatStateStr(new_state)))); } diff --git a/libtransmission/rpc-server.cc b/libtransmission/rpc-server.cc index a3d2beaf9dd..dc0b68ce1b5 100644 --- a/libtransmission/rpc-server.cc +++ b/libtransmission/rpc-server.cc @@ -102,7 +102,7 @@ class tr_unix_addr if (std::size(src) >= TrUnixAddrStrLen) { tr_logAddError(fmt::format( - _("Unix socket path must be fewer than {count} characters (including '{prefix}' prefix)"), + fmt::runtime(_("Unix socket path must be fewer than {count} characters (including '{prefix}' prefix)")), fmt::arg("count", TrUnixAddrStrLen - 1), fmt::arg("prefix", TrUnixSocketPrefix))); return false; @@ -614,8 +614,9 @@ bool bindUnixSocket( if (chmod(addr.sun_path, socket_mode) != 0) { - tr_logAddWarn( - fmt::format(_("Couldn't set RPC socket mode to {mode:#o}, defaulting to 0755"), fmt::arg("mode", socket_mode))); + tr_logAddWarn(fmt::format( + fmt::runtime(_("Couldn't set RPC socket mode to {mode:#o}, defaulting to 0755")), + fmt::arg("mode", socket_mode))); } return evhttp_bind_listener(httpd, lev) != nullptr; @@ -677,10 +678,10 @@ void start_server(tr_rpc_server* server) } tr_logAddError(fmt::format( - tr_ngettext( + fmt::runtime(tr_ngettext( "Couldn't bind to {address} after {count} attempt, giving up", "Couldn't bind to {address} after {count} attempts, giving up", - ServerStartRetryCount), + ServerStartRetryCount)), fmt::arg("address", addr_port_str), fmt::arg("count", ServerStartRetryCount))); } @@ -689,7 +690,9 @@ void start_server(tr_rpc_server* server) evhttp_set_gencb(httpd, handle_request, server); server->httpd.reset(httpd); - tr_logAddInfo(fmt::format(_("Listening for RPC and Web requests on '{address}'"), fmt::arg("address", addr_port_str))); + tr_logAddInfo(fmt::format( + fmt::runtime(_("Listening for RPC and Web requests on '{address}'")), + fmt::arg("address", addr_port_str))); } rpc_server_start_retry_cancel(server); @@ -717,7 +720,7 @@ void stop_server(tr_rpc_server* server) } tr_logAddInfo(fmt::format( - _("Stopped listening for RPC and Web requests on '{address}'"), + fmt::runtime(_("Stopped listening for RPC and Web requests on '{address}'")), fmt::arg("address", server->bind_address_->to_string(server->port())))); } @@ -739,7 +742,7 @@ auto parse_whitelist(std::string_view whitelist) auto const pos = whitelist.find_first_of(" ,;"sv); auto const token = tr_strv_strip(whitelist.substr(0, pos)); list.emplace_back(token); - tr_logAddInfo(fmt::format(_("Added '{entry}' to host whitelist"), fmt::arg("entry", token))); + tr_logAddInfo(fmt::format(fmt::runtime(_("Added '{entry}' to host whitelist")), fmt::arg("entry", token))); whitelist = pos == std::string_view::npos ? ""sv : whitelist.substr(pos + 1); } @@ -859,7 +862,8 @@ void tr_rpc_server::load(Settings&& settings) { // NOTE: bind_address_ is default initialized to INADDR_ANY tr_logAddWarn(fmt::format( - _("The '{key}' setting is '{value}' but must be an IPv4 or IPv6 address or a Unix socket path. Using default value '0.0.0.0'"), + fmt::runtime(_( + "The '{key}' setting is '{value}' but must be an IPv4 or IPv6 address or a Unix socket path. Using default value '0.0.0.0'")), fmt::arg("key", tr_quark_get_string_view(TR_KEY_rpc_bind_address)), fmt::arg("value", settings_.bind_address_str))); } @@ -872,7 +876,7 @@ void tr_rpc_server::load(Settings&& settings) if (this->is_enabled()) { auto const rpc_uri = bind_address_->to_string(port()) + settings_.url; - tr_logAddInfo(fmt::format(_("Serving RPC and Web requests on {address}"), fmt::arg("address", rpc_uri))); + tr_logAddInfo(fmt::format(fmt::runtime(_("Serving RPC and Web requests on {address}")), fmt::arg("address", rpc_uri))); session->run_in_session_thread(start_server, this); if (this->is_whitelist_enabled()) @@ -888,7 +892,8 @@ void tr_rpc_server::load(Settings&& settings) if (!std::empty(web_client_dir_)) { - tr_logAddInfo(fmt::format(_("Serving RPC and Web requests from '{path}'"), fmt::arg("path", web_client_dir_))); + tr_logAddInfo( + fmt::format(fmt::runtime(_("Serving RPC and Web requests from '{path}'")), fmt::arg("path", web_client_dir_))); } } diff --git a/libtransmission/rpcimpl.cc b/libtransmission/rpcimpl.cc index 7205024762a..aed863d9fc2 100644 --- a/libtransmission/rpcimpl.cc +++ b/libtransmission/rpcimpl.cc @@ -1155,7 +1155,7 @@ void onPortTested(tr_web::FetchResponse const& web_response) tr_idle_function_done( data, fmt::format( - _("Couldn't test port: {error} ({error_code})"), + fmt::runtime(_("Couldn't test port: {error} ({error_code})")), fmt::arg("error", tr_webGetResponseStr(status)), fmt::arg("error_code", status))); return; @@ -1210,7 +1210,7 @@ void onBlocklistFetched(tr_web::FetchResponse const& web_response) tr_idle_function_done( data, fmt::format( - _("Couldn't fetch blocklist: {error} ({error_code})"), + fmt::runtime(_("Couldn't fetch blocklist: {error} ({error_code})")), fmt::arg("error", tr_webGetResponseStr(status)), fmt::arg("error_code", status))); return; @@ -1255,7 +1255,7 @@ void onBlocklistFetched(tr_web::FetchResponse const& web_response) tr_idle_function_done( data, fmt::format( - _("Couldn't save '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't save '{path}': {error} ({error_code})")), fmt::arg("path", filename), fmt::arg("error", error.message()), fmt::arg("error_code", error.code()))); @@ -1337,7 +1337,7 @@ void onMetadataFetched(tr_web::FetchResponse const& web_response) tr_idle_function_done( data->data, fmt::format( - _("Couldn't fetch torrent: {error} ({error_code})"), + fmt::runtime(_("Couldn't fetch torrent: {error} ({error_code})")), fmt::arg("error", tr_webGetResponseStr(status)), fmt::arg("error_code", status))); } diff --git a/libtransmission/session-id.cc b/libtransmission/session-id.cc index d51d4c99993..75fd6741f07 100644 --- a/libtransmission/session-id.cc +++ b/libtransmission/session-id.cc @@ -65,7 +65,7 @@ tr_sys_file_t create_lockfile(std::string_view session_id) if (error) { tr_logAddWarn(fmt::format( - _("Couldn't create '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't create '{path}': {error} ({error_code})")), fmt::arg("path", lockfile_path), fmt::arg("error", error.message()), fmt::arg("error_code", error.code()))); @@ -147,7 +147,7 @@ bool tr_session_id::is_local(std::string_view session_id) noexcept if (error) { tr_logAddWarn(fmt::format( - _("Couldn't open session lock file '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't open session lock file '{path}': {error} ({error_code})")), fmt::arg("path", lockfile_path), fmt::arg("error", error.message()), fmt::arg("error_code", error.code()))); diff --git a/libtransmission/session.cc b/libtransmission/session.cc index 2bd1f22acd3..deb1bf57329 100644 --- a/libtransmission/session.cc +++ b/libtransmission/session.cc @@ -414,7 +414,7 @@ tr_session::BoundSocket::BoundSocket( } tr_logAddInfo(fmt::format( - _("Listening to incoming peer connections on {hostport}"), + fmt::runtime(_("Listening to incoming peer connections on {hostport}")), fmt::arg("hostport", tr_socket_address::display_name(addr, port)))); event_add(ev_.get(), nullptr); } @@ -732,7 +732,8 @@ void tr_session::initImpl(init_data& data) blocklists_.load(blocklist_dir_, blocklist_enabled()); - tr_logAddInfo(fmt::format(_("Transmission version {version} starting"), fmt::arg("version", LONG_VERSION_STRING))); + tr_logAddInfo( + fmt::format(fmt::runtime(_("Transmission version {version} starting")), fmt::arg("version", LONG_VERSION_STRING))); setSettings(settings, true); @@ -1418,7 +1419,8 @@ void tr_sessionClose(tr_session* session, size_t timeout_secs) TR_ASSERT(session != nullptr); TR_ASSERT(!session->am_in_session_thread()); - tr_logAddInfo(fmt::format(_("Transmission version {version} shutting down"), fmt::arg("version", LONG_VERSION_STRING))); + tr_logAddInfo( + fmt::format(fmt::runtime(_("Transmission version {version} shutting down")), fmt::arg("version", LONG_VERSION_STRING))); auto closed_promise = std::promise{}; auto closed_future = closed_promise.get_future(); @@ -1465,7 +1467,7 @@ void session_load_torrents(tr_session* session, tr_ctor* ctor, std::promiseerror().set_local_error(fmt::format( - _("Couldn't use metainfo from '{path}' for '{magnet}': {error} ({error_code})"), + fmt::runtime(_("Couldn't use metainfo from '{path}' for '{magnet}': {error} ({error_code})")), fmt::arg("path", filename), fmt::arg("magnet", tor->magnet()), fmt::arg("error", error.message()), @@ -399,7 +399,7 @@ void torrentCallScript(tr_torrent const* tor, std::string const& script) { "TR_TORRENT_TRACKERS"sv, trackers_str }, }; - tr_logAddInfoTor(tor, fmt::format(_("Calling script '{path}'"), fmt::arg("path", script))); + tr_logAddInfoTor(tor, fmt::format(fmt::runtime(_("Calling script '{path}'")), fmt::arg("path", script))); auto error = tr_error{}; if (!tr_spawn_async(std::data(cmd), env, TR_IF_WIN32("\\", "/"), &error)) @@ -407,7 +407,7 @@ void torrentCallScript(tr_torrent const* tor, std::string const& script) tr_logAddWarnTor( tor, fmt::format( - _("Couldn't call script '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't call script '{path}': {error} ({error_code})")), fmt::arg("path", script), fmt::arg("error", error.message()), fmt::arg("error_code", error.code()))); @@ -1079,7 +1079,7 @@ void tr_torrent::init(tr_ctor const& ctor) if (error) { this->error().set_local_error(fmt::format( - _("Couldn't save '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't save '{path}': {error} ({error_code})")), fmt::arg("path", filename), fmt::arg("error", error.message()), fmt::arg("error_code", error.code()))); @@ -1177,7 +1177,7 @@ void tr_torrent::set_location_in_session_thread(std::string_view const path, boo if (error) { this->error().set_local_error(fmt::format( - _("Couldn't move '{old_path}' to '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't move '{old_path}' to '{path}': {error} ({error_code})")), fmt::arg("old_path", current_dir()), fmt::arg("path", path), fmt::arg("error", error.message()), @@ -1683,7 +1683,7 @@ void tr_torrent::update_file_path(tr_file_index_t file, std::optional has_ tr_logAddErrorTor( this, fmt::format( - _("Couldn't move '{old_path}' to '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't move '{old_path}' to '{path}': {error} ({error_code})")), fmt::arg("old_path", oldpath), fmt::arg("path", newpath), fmt::arg("error", error.message()), @@ -2068,7 +2068,7 @@ bool tr_torrent::set_announce_list(tr_announce_list announce_list) if (save_error.has_value()) { error().set_local_error(fmt::format( - _("Couldn't save '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't save '{path}': {error} ({error_code})")), fmt::arg("path", filename), fmt::arg("error", save_error.message()), fmt::arg("error_code", save_error.code()))); @@ -2121,7 +2121,7 @@ void tr_torrent::on_tracker_response(tr_tracker_event const* event) tr_logAddWarnTor( this, fmt::format( - _("Tracker warning: '{warning}' ({url})"), + fmt::runtime(_("Tracker warning: '{warning}' ({url})")), fmt::arg("warning", event->text), fmt::arg("url", tr_urlTrackerLogName(event->announce_url)))); error_.set_tracker_warning(event->announce_url, event->text); diff --git a/libtransmission/tr-dht.cc b/libtransmission/tr-dht.cc index 9fc7b750da5..f72a669c1e6 100644 --- a/libtransmission/tr-dht.cc +++ b/libtransmission/tr-dht.cc @@ -550,7 +550,7 @@ class tr_dht_impl final : public tr_dht if (line_stream.bad() || std::empty(addrstr)) { tr_logAddWarn(fmt::format( - _("Couldn't parse '{filename}' line: '{line}'"), + fmt::runtime(_("Couldn't parse '{filename}' line: '{line}'")), fmt::arg("filename", filename), fmt::arg("line", line))); } @@ -574,7 +574,7 @@ class tr_dht_impl final : public tr_dht if (int const rc = getaddrinfo(name, port_str.c_str(), &hints, &info); rc != 0) { tr_logAddWarn(fmt::format( - _("Couldn't look up '{address}:{port}': {error} ({error_code})"), + fmt::runtime(_("Couldn't look up '{address}:{port}': {error} ({error_code})")), fmt::arg("address", name), fmt::arg("port", port_in.host()), fmt::arg("error", gai_strerror(rc)), diff --git a/libtransmission/tr-lpd.cc b/libtransmission/tr-lpd.cc index 9d4070e739c..daa4e39256a 100644 --- a/libtransmission/tr-lpd.cc +++ b/libtransmission/tr-lpd.cc @@ -267,7 +267,7 @@ class tr_lpd_impl final : public tr_lpd tr_net_close_socket(mcast_sockets_[TR_AF_INET]); mcast_sockets_[TR_AF_INET] = TR_BAD_SOCKET; tr_logAddWarn(fmt::format( - _("Couldn't initialize {ip_protocol} LPD: {error} ({error_code})"), + fmt::runtime(_("Couldn't initialize {ip_protocol} LPD: {error} ({error_code})")), fmt::arg("ip_protocol", tr_ip_protocol_to_sv(TR_AF_INET)), fmt::arg("error", tr_strerror(err)), fmt::arg("error_code", err))); @@ -280,7 +280,7 @@ class tr_lpd_impl final : public tr_lpd tr_net_close_socket(mcast_sockets_[TR_AF_INET6]); mcast_sockets_[TR_AF_INET6] = TR_BAD_SOCKET; tr_logAddWarn(fmt::format( - _("Couldn't initialize {ip_protocol} LPD: {error} ({error_code})"), + fmt::runtime(_("Couldn't initialize {ip_protocol} LPD: {error} ({error_code})")), fmt::arg("ip_protocol", tr_ip_protocol_to_sv(TR_AF_INET6)), fmt::arg("error", tr_strerror(err)), fmt::arg("error_code", err))); diff --git a/libtransmission/tr-udp.cc b/libtransmission/tr-udp.cc index 0b72d33e2ff..9aeb9432535 100644 --- a/libtransmission/tr-udp.cc +++ b/libtransmission/tr-udp.cc @@ -177,7 +177,7 @@ tr_session::tr_udp_core::tr_udp_core(tr_session& session, tr_port udp_port) { auto const error_code = errno; tr_logAddWarn(fmt::format( - _("Couldn't make IPv4 socket non-blocking {address}: {error} ({error_code})"), + fmt::runtime(_("Couldn't make IPv4 socket non-blocking {address}: {error} ({error_code})")), fmt::arg("address", tr_socket_address::display_name(addr, udp_port_)), fmt::arg("error", tr_strerror(error_code)), fmt::arg("error_code", error_code))); @@ -188,7 +188,7 @@ tr_session::tr_udp_core::tr_udp_core(tr_session& session, tr_port udp_port) { auto const error_code = errno; tr_logAddWarn(fmt::format( - _("Couldn't bind IPv4 socket {address}: {error} ({error_code})"), + fmt::runtime(_("Couldn't bind IPv4 socket {address}: {error} ({error_code})")), fmt::arg("address", tr_socket_address::display_name(addr, udp_port_)), fmt::arg("error", tr_strerror(error_code)), fmt::arg("error_code", error_code))); @@ -222,7 +222,7 @@ tr_session::tr_udp_core::tr_udp_core(tr_session& session, tr_port udp_port) { auto const error_code = errno; tr_logAddWarn(fmt::format( - _("Couldn't make IPv6 socket non-blocking {address}: {error} ({error_code})"), + fmt::runtime(_("Couldn't make IPv6 socket non-blocking {address}: {error} ({error_code})")), fmt::arg("address", tr_socket_address::display_name(addr, udp_port_)), fmt::arg("error", tr_strerror(error_code)), fmt::arg("error_code", error_code))); @@ -233,7 +233,7 @@ tr_session::tr_udp_core::tr_udp_core(tr_session& session, tr_port udp_port) { auto const error_code = errno; tr_logAddWarn(fmt::format( - _("Couldn't bind IPv6 socket {address}: {error} ({error_code})"), + fmt::runtime(_("Couldn't bind IPv6 socket {address}: {error} ({error_code})")), fmt::arg("address", tr_socket_address::display_name(addr, udp_port_)), fmt::arg("error", tr_strerror(error_code)), fmt::arg("error_code", error_code))); diff --git a/libtransmission/utils.cc b/libtransmission/utils.cc index ce709002cc0..7acd714cca4 100644 --- a/libtransmission/utils.cc +++ b/libtransmission/utils.cc @@ -134,7 +134,7 @@ bool tr_file_read(std::string_view filename, std::vector& contents, tr_err if (*error) { tr_logAddError(fmt::format( - _("Couldn't read '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't read '{path}': {error} ({error_code})")), fmt::arg("path", filename), fmt::arg("error", error->message()), fmt::arg("error_code", error->code()))); @@ -143,7 +143,7 @@ bool tr_file_read(std::string_view filename, std::vector& contents, tr_err if (!info || !info->isFile()) { - tr_logAddError(fmt::format(_("Couldn't read '{path}': Not a regular file"), fmt::arg("path", filename))); + tr_logAddError(fmt::format(fmt::runtime(_("Couldn't read '{path}': Not a regular file")), fmt::arg("path", filename))); error->set(TR_ERROR_EISDIR, "Not a regular file"sv); return false; } @@ -153,7 +153,7 @@ bool tr_file_read(std::string_view filename, std::vector& contents, tr_err if (fd == TR_BAD_SYS_FILE) { tr_logAddError(fmt::format( - _("Couldn't read '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't read '{path}': {error} ({error_code})")), fmt::arg("path", filename), fmt::arg("error", error->message()), fmt::arg("error_code", error->code()))); @@ -164,7 +164,7 @@ bool tr_file_read(std::string_view filename, std::vector& contents, tr_err if (!tr_sys_file_read(fd, std::data(contents), info->size, nullptr, error)) { tr_logAddError(fmt::format( - _("Couldn't read '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't read '{path}': {error} ({error_code})")), fmt::arg("path", filename), fmt::arg("error", error->message()), fmt::arg("error_code", error->code()))); @@ -624,7 +624,7 @@ bool tr_file_move(std::string_view oldpath_in, std::string_view newpath_in, bool if (auto log_error = tr_error{}; !tr_sys_path_remove(oldpath, &log_error)) { tr_logAddError(fmt::format( - _("Couldn't remove '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't remove '{path}': {error} ({error_code})")), fmt::arg("path", oldpath), fmt::arg("error", log_error.message()), fmt::arg("error_code", log_error.code()))); diff --git a/libtransmission/variant-json.cc b/libtransmission/variant-json.cc index ae1041b9927..e51ef0877f5 100644 --- a/libtransmission/variant-json.cc +++ b/libtransmission/variant-json.cc @@ -238,7 +238,7 @@ std::optional tr_variant_serde::parse_json(std::string_view input) error_.set( EILSEQ, fmt::format( - _("Couldn't parse JSON at position {position} '{text}': {error} ({error_code})"), + fmt::runtime(_("Couldn't parse JSON at position {position} '{text}': {error} ({error_code})")), fmt::arg("position", pos), fmt::arg("text", std::string_view{ begin + pos, std::min(size_t{ 16U }, size - pos) }), fmt::arg("error", rapidjson::GetParseError_En(err_code)), diff --git a/libtransmission/variant.cc b/libtransmission/variant.cc index cfbd35f8cad..3307ba059f2 100644 --- a/libtransmission/variant.cc +++ b/libtransmission/variant.cc @@ -865,7 +865,7 @@ bool tr_variant_serde::to_file(tr_variant const& var, std::string_view filename) if (error_) { tr_logAddError(fmt::format( - _("Couldn't save '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't save '{path}': {error} ({error_code})")), fmt::arg("path", filename), fmt::arg("error", error_.message()), fmt::arg("error_code", error_.code()))); diff --git a/libtransmission/watchdir-inotify.cc b/libtransmission/watchdir-inotify.cc index b297a359f68..889c27bf86e 100644 --- a/libtransmission/watchdir-inotify.cc +++ b/libtransmission/watchdir-inotify.cc @@ -83,7 +83,7 @@ class INotifyWatchdir final : public impl::BaseWatchdir { auto const error_code = errno; tr_logAddError(fmt::format( - _("Couldn't watch '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't watch '{path}': {error} ({error_code})")), fmt::arg("path", dirname()), fmt::arg("error", tr_strerror(error_code)), fmt::arg("error_code", error_code))); @@ -95,7 +95,7 @@ class INotifyWatchdir final : public impl::BaseWatchdir { auto const error_code = errno; tr_logAddError(fmt::format( - _("Couldn't watch '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't watch '{path}': {error} ({error_code})")), fmt::arg("path", dirname()), fmt::arg("error", tr_strerror(error_code)), fmt::arg("error_code", error_code))); @@ -107,7 +107,7 @@ class INotifyWatchdir final : public impl::BaseWatchdir { auto const error_code = errno; tr_logAddError(fmt::format( - _("Couldn't watch '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't watch '{path}': {error} ({error_code})")), fmt::arg("path", dirname()), fmt::arg("error", tr_strerror(error_code)), fmt::arg("error_code", error_code))); @@ -139,7 +139,7 @@ class INotifyWatchdir final : public impl::BaseWatchdir { auto const error_code = errno; tr_logAddError(fmt::format( - _("Couldn't read event: {error} ({error_code})"), + fmt::runtime(_("Couldn't read event: {error} ({error_code})")), fmt::arg("error", tr_strerror(error_code)), fmt::arg("error_code", error_code))); break; @@ -148,7 +148,7 @@ class INotifyWatchdir final : public impl::BaseWatchdir if (nread != sizeof(ev)) { tr_logAddError(fmt::format( - _("Couldn't read event: expected {expected_size}, got {actual_size}"), + fmt::runtime(_("Couldn't read event: expected {expected_size}, got {actual_size}")), fmt::arg("expected_size", sizeof(ev)), fmt::arg("actual_size", nread))); break; @@ -165,7 +165,7 @@ class INotifyWatchdir final : public impl::BaseWatchdir { auto const error_code = errno; tr_logAddError(fmt::format( - _("Couldn't read filename: {error} ({error_code})"), + fmt::runtime(_("Couldn't read filename: {error} ({error_code})")), fmt::arg("error", tr_strerror(error_code)), fmt::arg("error_code", error_code))); break; @@ -174,7 +174,7 @@ class INotifyWatchdir final : public impl::BaseWatchdir if (nread != ev.len) { tr_logAddError(fmt::format( - _("Couldn't read filename: expected {expected_size}, got {actual_size}"), + fmt::runtime(_("Couldn't read filename: expected {expected_size}, got {actual_size}")), fmt::arg("expected_size", sizeof(ev)), fmt::arg("actual_size", nread))); break; diff --git a/libtransmission/watchdir.cc b/libtransmission/watchdir.cc index cc1dddac119..760d36659a6 100644 --- a/libtransmission/watchdir.cc +++ b/libtransmission/watchdir.cc @@ -49,7 +49,7 @@ namespace if (error && !tr_error_is_enoent(error.code())) { tr_logAddWarn(fmt::format( - _("Skipping '{path}': {error} ({error_code})"), + fmt::runtime(_("Skipping '{path}': {error} ({error_code})")), fmt::arg("path", path), fmt::arg("error", error.message()), fmt::arg("error_code", error.code()))); @@ -88,7 +88,7 @@ void BaseWatchdir::processFile(std::string_view basename) if (now - info.first_kick_at > timeoutDuration()) { - tr_logAddWarn(fmt::format(_("Couldn't add torrent file '{path}'"), fmt::arg("path", basename))); + tr_logAddWarn(fmt::format(fmt::runtime(_("Couldn't add torrent file '{path}'")), fmt::arg("path", basename))); pending_.erase(iter); } else @@ -115,7 +115,7 @@ void BaseWatchdir::scan() if (error) { tr_logAddWarn(fmt::format( - _("Couldn't read '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't read '{path}': {error} ({error_code})")), fmt::arg("path", dirname()), fmt::arg("error", error.message()), fmt::arg("error_code", error.code()))); diff --git a/libtransmission/web.cc b/libtransmission/web.cc index 628f72b83ab..c449a784999 100644 --- a/libtransmission/web.cc +++ b/libtransmission/web.cc @@ -181,8 +181,9 @@ class tr_web::Impl if (curl_ssl_verify) { auto const* bundle = std::empty(curl_ca_bundle) ? "none" : curl_ca_bundle.c_str(); - tr_logAddInfo( - fmt::format(_("Will verify tracker certs using envvar CURL_CA_BUNDLE: {bundle}"), fmt::arg("bundle", bundle))); + tr_logAddInfo(fmt::format( + fmt::runtime(_("Will verify tracker certs using envvar CURL_CA_BUNDLE: {bundle}")), + fmt::arg("bundle", bundle))); tr_logAddInfo(_("NB: this only works if you built against libcurl with openssl or gnutls, NOT nss")); tr_logAddInfo(_("NB: Invalid certs will appear as 'Could not connect to tracker' like many other errors")); } @@ -460,7 +461,7 @@ class tr_web::Impl if (code != NoResponseCode && code != PartialContentResponseCode) { tr_logAddWarn(fmt::format( - _("Couldn't fetch '{url}': expected HTTP response code {expected_code}, got {actual_code}"), + fmt::runtime(_("Couldn't fetch '{url}': expected HTTP response code {expected_code}, got {actual_code}")), fmt::arg("url", task->url()), fmt::arg("expected_code", PartialContentResponseCode), fmt::arg("actual_code", code))); diff --git a/tests/libtransmission/dht-test.cc b/tests/libtransmission/dht-test.cc index 40123acd0d3..2fd223b6967 100644 --- a/tests/libtransmission/dht-test.cc +++ b/tests/libtransmission/dht-test.cc @@ -395,7 +395,7 @@ class DhtTest : public SandboxedTest if (int const rc = getaddrinfo(szname.c_str(), std::data(port_str), &hints, &info); rc != 0) { tr_logAddWarn(fmt::format( - _("Couldn't look up '{address}:{port}': {error} ({error_code})"), + fmt::runtime(_("Couldn't look up '{address}:{port}': {error} ({error_code})")), fmt::arg("address", name), fmt::arg("port", port.host()), fmt::arg("error", gai_strerror(rc)), diff --git a/utils/create.cc b/utils/create.cc index f2871cca48e..52bbaa34e4b 100644 --- a/utils/create.cc +++ b/utils/create.cc @@ -232,15 +232,16 @@ int tr_main(int argc, char* argv[]) } fmt::print( - tr_ngettext("{file_count:L} file, {total_size}\n", "{file_count:L} files, {total_size}\n", builder.file_count()), + fmt::runtime( + tr_ngettext("{file_count:L} file, {total_size}\n", "{file_count:L} files, {total_size}\n", builder.file_count())), fmt::arg("file_count", builder.file_count()), fmt::arg("total_size", Storage{ builder.total_size(), Storage::Units::Bytes }.to_string())); fmt::print( - tr_ngettext( + fmt::runtime(tr_ngettext( "{piece_count:L} piece, {piece_size}\n", "{piece_count:L} pieces, {piece_size} each\n", - builder.piece_count()), + builder.piece_count())), fmt::arg("piece_count", builder.piece_count()), fmt::arg("piece_size", Memory{ builder.piece_size(), Memory::Units::Bytes }.to_string())); diff --git a/utils/remote.cc b/utils/remote.cc index 8e1047ecbbc..af8ab3e50fd 100644 --- a/utils/remote.cc +++ b/utils/remote.cc @@ -936,7 +936,7 @@ void print_details(tr_variant::Map const& map) { if (auto sv = it->value_if(); sv) { - fmt::print(it == begin ? "{:s}" : ", {:s}", *sv); + fmt::print(fmt::runtime(it == begin ? "{:s}" : ", {:s}"), *sv); } }