feat support log file template render {{date}}
Some checks failed
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (push) Successful in 1m48s
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Successful in 1m53s
linux-arm-gcc / linux-gcc-armhf (push) Successful in 2m6s
linux-x64-gcc / linux-gcc (Release) (push) Successful in 2m7s
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Successful in 3m35s
linux-x64-gcc / linux-gcc (Debug) (push) Has been cancelled

This commit is contained in:
tqcq 2024-05-27 10:50:13 +08:00
parent 4b159b8e44
commit 0330fd7bc5

View File

@ -98,7 +98,7 @@ GetCurrentUTCTime()
}
static LogLevel g_log_level = LogLevel::kTrace;
static std::string g_log_file_name;
// static std::string g_log_file_name;
static std::ofstream g_log_stream;
void
@ -110,8 +110,12 @@ SetLogLevel(LogLevel level)
void
SetLogFileName(const char *file_name)
{
g_log_file_name = file_name;
g_log_stream.open(file_name, std::ios_base::app);
std::ofstream tmp_stream(file_name, std::ios_base::app);
if (tmp_stream.is_open()) {
g_log_stream.open(file_name, std::ios_base::app);
} else {
LOGE("log", "can't open new log file [{}]", file_name);
}
}
static std::atomic<uint32_t> g_current_id(0);