Loading src/sled/log/log.cc +15 −2 Original line number Diff line number Diff line Loading @@ -97,6 +97,18 @@ GetCurrentUTCTime() 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_request_id(0); Loading Loading @@ -148,12 +160,13 @@ Log(LogLevel level, const char *tag, const char *fmt, const char *file_name, int { if (level < g_log_level) { return; } auto utc_time = GetCurrentUTCTime(); // auto cur_time = GetCurrentUTCTime(); auto cur_time = GetLocalTime(); auto level_str = ToShortString(level); int len = file_name ? strlen(file_name) : 0; 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.wait(); Loading Loading
src/sled/log/log.cc +15 −2 Original line number Diff line number Diff line Loading @@ -97,6 +97,18 @@ GetCurrentUTCTime() 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_request_id(0); Loading Loading @@ -148,12 +160,13 @@ Log(LogLevel level, const char *tag, const char *fmt, const char *file_name, int { if (level < g_log_level) { return; } auto utc_time = GetCurrentUTCTime(); // auto cur_time = GetCurrentUTCTime(); auto cur_time = GetLocalTime(); auto level_str = ToShortString(level); int len = file_name ? strlen(file_name) : 0; 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.wait(); Loading