feat update log
Some checks failed
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (push) Successful in 1m47s
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Successful in 1m48s
linux-x64-gcc / linux-gcc (Release) (push) Successful in 2m16s
linux-x64-gcc / linux-gcc (Debug) (push) Successful in 2m37s
linux-arm-gcc / linux-gcc-armhf (push) Successful in 2m50s
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Failing after 3h14m19s
Some checks failed
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (push) Successful in 1m47s
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Successful in 1m48s
linux-x64-gcc / linux-gcc (Release) (push) Successful in 2m16s
linux-x64-gcc / linux-gcc (Debug) (push) Successful in 2m37s
linux-arm-gcc / linux-gcc-armhf (push) Successful in 2m50s
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Failing after 3h14m19s
This commit is contained in:
parent
45b1c02b88
commit
c01b15bcd7
@ -118,7 +118,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
static LogLevel g_log_level = LogLevel::kTrace;
|
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;
|
static std::ofstream g_log_stream;
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -132,12 +132,13 @@ SetLogFileName(const char *file_name)
|
|||||||
{
|
{
|
||||||
std::ofstream tmp_stream(file_name, std::ios_base::app);
|
std::ofstream tmp_stream(file_name, std::ios_base::app);
|
||||||
if (tmp_stream.is_open()) {
|
if (tmp_stream.is_open()) {
|
||||||
// g_log_stream.open(file_name, std::ios_base::app);
|
|
||||||
// g_log_stream = std::move(tmp_stream);
|
|
||||||
Waiter waiter(g_request_id.fetch_add(1), g_current_id);
|
Waiter waiter(g_request_id.fetch_add(1), g_current_id);
|
||||||
|
waiter.wait();
|
||||||
|
g_log_file_name = file_name;
|
||||||
std::swap(g_log_stream, tmp_stream);
|
std::swap(g_log_stream, tmp_stream);
|
||||||
} else {
|
} else {
|
||||||
LOGE("log", "can't open new log file [{}]", file_name);
|
LOGE("log", "can't open new log file [{}]", file_name);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
LOGD("log", "log to new file [{}]", file_name);
|
LOGD("log", "log to new file [{}]", file_name);
|
||||||
}
|
}
|
||||||
@ -156,6 +157,7 @@ Log(LogLevel level, const char *tag, const char *fmt, const char *file_name, int
|
|||||||
|
|
||||||
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();
|
||||||
|
|
||||||
if (g_log_stream.is_open()) { g_log_stream << msg << std::endl; }
|
if (g_log_stream.is_open()) { g_log_stream << msg << std::endl; }
|
||||||
std::cout << GetConsoleColorPrefix(level) << msg << GetConsoleColorSuffix() << std::endl;
|
std::cout << GetConsoleColorPrefix(level) << msg << GetConsoleColorSuffix() << std::endl;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user