Skip to content

Commit

Permalink
🐛 fix log bug
Browse files Browse the repository at this point in the history
  • Loading branch information
markparticle committed Sep 23, 2020
1 parent 2ae01bc commit dae8a91
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions code/log/log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void Log::init(int level = 1, const char* path, const char* suffix,
lock_guard<mutex> locker(mtx_);
buff_.RetrieveAll();
if(fp_) {
fflush(fp_);
flush();
fclose(fp_);
}

Expand Down Expand Up @@ -116,7 +116,7 @@ void Log::write(int level, const char *format, ...) {
}

locker.lock();
fflush(fp_);
flush();
fclose(fp_);
fp_ = fopen(newFile, "a");
assert(fp_ != nullptr);
Expand Down Expand Up @@ -168,14 +168,11 @@ void Log::AppendLogLevelTitle_(int level) {
}
}

void Log::flush(void) {
{
lock_guard<mutex> locker(mtx_);
fflush(fp_);
}
void Log::flush() {
if(isAsync_) {
deque_->flush();
}
fflush(fp_);
}

void Log::AsyncWrite_() {
Expand Down

0 comments on commit dae8a91

Please sign in to comment.