feat fix daily log
Some checks failed
linux-arm-gcc / linux-gcc-armhf (push) Successful in 2m0s
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Successful in 2m20s
linux-x64-gcc / linux-gcc (Release) (push) Successful in 2m18s
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Successful in 2m21s
linux-x64-gcc / linux-gcc (Debug) (push) Successful in 2m37s
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (push) Failing after 3h13m1s

This commit is contained in:
tqcq 2024-05-29 11:56:34 +08:00
parent c01b15bcd7
commit 00788da459

View File

@ -97,6 +97,18 @@ GetCurrentUTCTime()
return result; return result;
} }
std::string
GetLocalTime(std::string fmt = "%Y-%m-%dT%H:%M:%S")
{
time_t rawtime;
struct tm *timeinfo;
char buffer[120];
time(&rawtime);
timeinfo = localtime(&rawtime);
strftime(buffer, sizeof(buffer), fmt.c_str(), timeinfo);
return buffer;
}
static std::atomic<uint32_t> g_current_id(0); static std::atomic<uint32_t> g_current_id(0);
static std::atomic<uint32_t> g_request_id(0); static std::atomic<uint32_t> g_request_id(0);
@ -148,12 +160,13 @@ Log(LogLevel level, const char *tag, const char *fmt, const char *file_name, int
{ {
if (level < g_log_level) { return; } if (level < g_log_level) { return; }
auto utc_time = GetCurrentUTCTime(); // auto cur_time = GetCurrentUTCTime();
auto cur_time = GetLocalTime();
auto level_str = ToShortString(level); auto level_str = ToShortString(level);
int len = file_name ? strlen(file_name) : 0; int len = file_name ? strlen(file_name) : 0;
while (len > 0 && file_name[len - 1] != '/') { len--; } while (len > 0 && file_name[len - 1] != '/') { len--; }
auto msg = fmt::format("{} {} {} {}:{}@{}: {}", utc_time, level_str, tag, file_name + len, line, func_name, fmt); auto msg = fmt::format("{} {} {} {}:{}@{}: {}", cur_time, level_str, tag, file_name + len, line, func_name, fmt);
Waiter waiter(g_request_id.fetch_add(1), g_current_id); Waiter waiter(g_request_id.fetch_add(1), g_current_id);
waiter.wait(); waiter.wait();