refactor: remove tr_strvJoin() (#2896)

This commit is contained in:
Charles Kerr
2022-04-07 17:26:59 -05:00
committed by GitHub
parent ffda5bb68a
commit 31c65eec1f
23 changed files with 97 additions and 105 deletions

View File

@@ -11,6 +11,8 @@
#include <fcntl.h> /* open() */
#include <unistd.h> /* fork(), setsid(), chdir(), dup2(), close(), pipe() */
#include <fmt/format.h>
#include <libtransmission/transmission.h>
#include <libtransmission/error.h>
#include <libtransmission/utils.h>
@@ -34,7 +36,7 @@ static int signal_pipe[2];
static void set_system_error(tr_error** error, int code, std::string_view message)
{
tr_error_set(error, code, tr_strvJoin(message, " ("sv, std::to_string(code), "): "sv, tr_strerror(code)));
tr_error_set(error, code, fmt::format(FMT_STRING("{:s}: {:s} ({:d}"), message, tr_strerror(code), code));
}
/***

View File

@@ -339,14 +339,14 @@ static void printMessage(
std::string_view filename,
int line)
{
auto const out = std::empty(name) ? tr_strvJoin(message, " ("sv, filename, ":"sv, std::to_string(line), ")"sv) :
tr_strvJoin(name, " "sv, message, " ("sv, filename, ":"sv, std::to_string(line), ")"sv);
auto const out = std::empty(name) ? fmt::format(FMT_STRING("{:s} ({:s}:{:d}"), message, filename, line) :
fmt::format(FMT_STRING("{:s} {:s} ({:s}:{:d}"), name, message, filename, line);
if (file != TR_BAD_SYS_FILE)
{
auto timestr = std::array<char, 64>{};
tr_logGetTimeStr(std::data(timestr), std::size(timestr));
tr_sys_file_write_line(file, tr_strvJoin("["sv, std::data(timestr), "] "sv, levelName(level), " "sv, out));
tr_sys_file_write_line(file, fmt::format(FMT_STRING("[{:s}] {:s} {:s}"), std::data(timestr), levelName(level), out));
}
#ifdef HAVE_SYSLOG
@@ -980,7 +980,8 @@ int tr_main(int argc, char* argv[])
if (tr_error* error = nullptr; !dtr_daemon(&cb, &data, foreground, &ret, &error))
{
printMessage(logfile, TR_LOG_ERROR, MyName, tr_strvJoin("Couldn't daemonize: ", error->message), __FILE__, __LINE__);
auto const errmsg = fmt::format(FMT_STRING("Couldn't daemonize: {:s} ({:d})"), error->message, error->code);
printMessage(logfile, TR_LOG_ERROR, MyName, errmsg, __FILE__, __LINE__);
tr_error_free(error);
}