From 1debbc0cc3fe92af3c9c324e7554655e50eaa154 Mon Sep 17 00:00:00 2001 From: mark Date: Tue, 7 Jul 2020 15:39:17 +0800 Subject: [PATCH] :bug: fix bug --- code/log/log.cpp | 9 +++++++-- code/log/log.h | 1 - 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/code/log/log.cpp b/code/log/log.cpp index 46bc929..c0f518d 100644 --- a/code/log/log.cpp +++ b/code/log/log.cpp @@ -169,8 +169,13 @@ void Log::AppendLogLevelTitle_(int level) { } void Log::flush(void) { - lock_guard locker(mtx_); - fflush(fp_); + { + lock_guard locker(mtx_); + fflush(fp_); + } + if(isAsync_) { + deque_->flush(); + } } void Log::AsyncWrite_() { diff --git a/code/log/log.h b/code/log/log.h index 6bb1a7b..c26b3cd 100644 --- a/code/log/log.h +++ b/code/log/log.h @@ -70,7 +70,6 @@ class Log { if (log->IsOpen() && log->GetLevel() <= level) {\ log->write(level, format, ##__VA_ARGS__); \ log->flush();\ - if(isAsync_) { deque_->flush(); } \ }\ } while(0);