27 inline std::string
format(
const char *fmt, ...) {
28# ifdef LOGIT_USE_FMT_LIB
31 std::string result = fmt::vformat(fmt, fmt::make_format_args(args));
37 std::vector<char> buffer(1024);
40 va_copy(args_copy, args);
41 int res = vsnprintf(buffer.data(), buffer.size(), fmt, args_copy);
44 if ((res >= 0) && (res <
static_cast<int>(buffer.size()))) {
46 return std::string(buffer.data());
50 const size_t size = res < 0 ? buffer.size() * 2 :
static_cast<size_t>(res) + 1;
67 inline std::string
format(
const std::string& fmt, ...) {
70 std::vector<char> buffer(1024);
73 va_copy(args_copy, args);
74 int res = vsnprintf(buffer.data(), buffer.size(), fmt.c_str(), args_copy);
77 if ((res >= 0) && (res <
static_cast<int>(buffer.size()))) {
79 return std::string(buffer.data());
83 const size_t size = res < 0 ? buffer.size() * 2 :
static_cast<size_t>(res) + 1;
108 inline std::string format_string(
const std::string& fmt, Args&&... args) {