feat update
Some checks failed
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Waiting to run
linux-x64-gcc / linux-gcc (Debug) (push) Waiting to run
linux-x64-gcc / linux-gcc (Release) (push) Waiting to run
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (push) Failing after 45s
linux-arm-gcc / linux-gcc-armhf (push) Failing after 34s
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Has been cancelled
Some checks failed
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Waiting to run
linux-x64-gcc / linux-gcc (Debug) (push) Waiting to run
linux-x64-gcc / linux-gcc (Release) (push) Waiting to run
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (push) Failing after 45s
linux-arm-gcc / linux-gcc-armhf (push) Failing after 34s
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Has been cancelled
This commit is contained in:
parent
97681c8807
commit
c06ae29c2f
@ -142,12 +142,14 @@ SetLogLevel(LogLevel level)
|
|||||||
void
|
void
|
||||||
SetLogFileName(const char *file_name)
|
SetLogFileName(const char *file_name)
|
||||||
{
|
{
|
||||||
std::ofstream tmp_stream(file_name, std::ios_base::app);
|
|
||||||
if (tmp_stream.is_open()) {
|
if (tmp_stream.is_open()) {
|
||||||
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();
|
||||||
|
g_log_stream.close();
|
||||||
|
|
||||||
g_log_file_name = file_name;
|
g_log_file_name = file_name;
|
||||||
std::swap(g_log_stream, tmp_stream);
|
std::ofstream tmp_stream(file_name, std::ios_base::app);
|
||||||
|
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;
|
return;
|
||||||
@ -171,7 +173,10 @@ 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;
|
||||||
|
if (waiter.id() % 100 == 99) { g_log_stream.flush(); }
|
||||||
|
}
|
||||||
std::cout << GetConsoleColorPrefix(level) << msg << GetConsoleColorSuffix() << std::endl;
|
std::cout << GetConsoleColorPrefix(level) << msg << GetConsoleColorSuffix() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user