modify logs

This commit is contained in:
lnk
2025-09-24 09:44:52 +08:00
parent e997c88d82
commit 4fe8aee149
6 changed files with 43 additions and 24 deletions

View File

@@ -7,6 +7,7 @@
#include <array>
#include <map>
#include <mutex>
#include <sstream>
///////////////////////////////////////////////////////////////////////////////////////////
@@ -695,9 +696,23 @@ inline std::string sanitize(std::string s) {
}
return s;
}
// 当前本地时间,格式 "YYYY-MM-DD HH:MM:SS"
inline std::string now_yyyy_mm_dd_hh_mm_ss() {
std::time_t t = std::time(nullptr);
std::tm tmv;
#if defined(_WIN32)
localtime_s(&tmv, &t); // Windows 线程安全
#else
localtime_r(&t, &tmv); // POSIX 线程安全
#endif
std::ostringstream oss;
oss << std::put_time(&tmv, "%Y-%m-%d %H:%M:%S");
return oss.str();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
extern int g_front_seg_index;
extern std::string FRONT_IP;
extern std::string FRONT_INST;
extern std::string FRONT_PATH;
extern std::string WEB_FILEUPLOAD;