mirror of
https://github.com/transmission/transmission
synced 2025-02-25 23:42:30 +00:00
refactor: a little more logging (#2800)
Co-authored-by: Mike Gelfand <mikedld@mikedld.com>
This commit is contained in:
parent
6e1b89d9a7
commit
04a4f4a10c
7 changed files with 21 additions and 9 deletions
|
@ -67,7 +67,7 @@ static void log_cyassl_error(int error_code, char const* file, int line)
|
|||
TR_LOG_ERROR,
|
||||
fmt::format(
|
||||
_("{crypto_library} error: {error} ({error_code})"),
|
||||
fmt::arg("crypto_library", "CyaSSL"),
|
||||
fmt::arg("crypto_library", "CyaSSL/WolfSSL"),
|
||||
fmt::arg("error", error_message),
|
||||
fmt::arg("error_code", error_code)));
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ static void log_polarssl_error(int error_code, char const* file, int line)
|
|||
TR_LOG_ERROR,
|
||||
fmt::format(
|
||||
_("{crypto_library} error: {error} ({error_code})"),
|
||||
fmt::arg("crypto_library", "PolarSSL"),
|
||||
fmt::arg("crypto_library", "PolarSSL/MbedTLS"),
|
||||
fmt::arg("error", error_message),
|
||||
fmt::arg("error_code", error_code)));
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ void tr_logAddMessage(
|
|||
int source_line,
|
||||
tr_log_level level,
|
||||
std::string_view message,
|
||||
std::string_view module_name = "");
|
||||
std::string_view module_name = {});
|
||||
|
||||
#define tr_logAddLevel(level, ...) \
|
||||
do \
|
||||
|
|
|
@ -425,14 +425,13 @@ static void utp_on_read(void* vio, unsigned char const* buf, size_t buflen)
|
|||
TR_ASSERT(tr_isPeerIo(io));
|
||||
|
||||
int rc = evbuffer_add(io->inbuf, buf, buflen);
|
||||
tr_logAddTraceIo(io, fmt::format("utp_on_read got {} bytes", buflen));
|
||||
|
||||
if (rc < 0)
|
||||
{
|
||||
tr_logAddError("On read evbuffer_add");
|
||||
tr_logAddWarn(_("Couldn't write to peer"));
|
||||
return;
|
||||
}
|
||||
|
||||
tr_logAddTraceIo(io, fmt::format("utp_on_read got {} bytes", buflen));
|
||||
tr_peerIoSetEnabled(io, TR_DOWN, true);
|
||||
canReadWrapper(io);
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ static void natPulse(tr_shared* s, bool do_check)
|
|||
session->public_peer_port = public_peer_port;
|
||||
session->private_peer_port = received_private_port;
|
||||
tr_logAddInfo(fmt::format(
|
||||
_("Mapped private port '{private_port}' to public port '{public_port}'"),
|
||||
_("Mapped private port {private_port} to public port {public_port}"),
|
||||
fmt::arg("public_port", session->public_peer_port),
|
||||
fmt::arg("private_port", session->private_peer_port)));
|
||||
}
|
||||
|
|
|
@ -311,7 +311,15 @@ static void onHaveAllMetainfo(tr_torrent* tor, tr_incomplete_metadata* m)
|
|||
|
||||
m->piecesNeededCount = n;
|
||||
char const* const msg = error != nullptr && error->message != nullptr ? error->message : "unknown error";
|
||||
tr_logAddWarnTor(tor, fmt::format("metadata error: {}. (trying again; {} pieces left)", msg, n));
|
||||
tr_logAddWarnTor(
|
||||
tor,
|
||||
fmt::format(
|
||||
ngettext(
|
||||
"Couldn't parse magnet metainfo: '{error}'. Redownloading {piece_count} piece",
|
||||
"Couldn't parse magnet metainfo: '{error}'. Redownloading {piece_count} pieces",
|
||||
n),
|
||||
fmt::arg("error", msg),
|
||||
fmt::arg("piece_count", n)));
|
||||
tr_error_clear(&error);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,7 +112,12 @@ static void bootstrap_from_name(char const* name, tr_port port, int af)
|
|||
addrinfo* info = nullptr;
|
||||
if (int const rc = getaddrinfo(name, pp, &hints, &info); rc != 0)
|
||||
{
|
||||
tr_logAddWarn(fmt::format("{}:{}: {}", name, pp, gai_strerror(rc)));
|
||||
tr_logAddWarn(fmt::format(
|
||||
_("Couldn't look up '{addresss}:{port}': {error} ({error_code})"),
|
||||
fmt::arg("address", name),
|
||||
fmt::arg("port", port),
|
||||
fmt::arg("error", gai_strerror(rc)),
|
||||
fmt::arg("error_code", rc)));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue