29 thread_local std::array<char, 4096> buffer;
33 if (
sizeof...(args) == 0) {
37 len = std::snprintf(buffer.data(), buffer.size(), fmt, std::forward<Args>(args)...);
38 if (len < 0)
return {};
39 if (len >=
static_cast<int>(buffer.size())) len = buffer.size() - 1;
40 f_msg = std::string(buffer.data(), len);
42 auto t =
static_cast<std::time_t
>(pack.time / 1000);
43 const auto ms =
static_cast<short>(pack.time % 1000);
48 #elif defined(__linux__) || defined(__APPLE__) || defined(__unix__)
51 tm = *std::localtime(&t);
54 thread_local std::array<char, 64> time;
55 std::strftime(time.data(), time.size(),
"%Y-%m-%d %H:%M:%S", &tm);
56 thread_local std::array<char, 80> ms_time;
57 std::snprintf(ms_time.data(), ms_time.size(),
"%s.%03d", time.data(), ms);
59 len = std::snprintf(buffer.data(), buffer.size(),
61 ms_time.data(), pack.name->c_str(), f_msg.c_str());
62 if (len < 0)
return {};
63 if (len >=
static_cast<int>(buffer.size())) len = buffer.size() - 1;
64 return {buffer.data(), buffer.data() + len};