Skip to content

Commit

Permalink
add FlushAll for xlog
Browse files Browse the repository at this point in the history
  • Loading branch information
garryyan committed Aug 10, 2022
1 parent 45e8a74 commit 6adbe2c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions mars/log/src/xlogger_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,17 @@ void Flush(uintptr_t _instance_ptr, bool _is_sync) {
}
}

void FlushAll(bool _is_sync) {
_is_sync ? appender_flush_sync() : appender_flush();
ScopedLock lock(sg_mutex);
// loop through all categories
for (auto it = sg_map.begin(); it != sg_map.end(); ++it) {
XloggerCategory* category = it->second;
XloggerAppender* appender = reinterpret_cast<XloggerAppender*>(category->GetAppender());
_is_sync ? appender->FlushSync() : appender->Flush();
}
}

void SetConsoleLogOpen(uintptr_t _instance_ptr, bool _is_open) {
if (0 == _instance_ptr) {
appender_set_console_log(_is_open);
Expand Down
2 changes: 2 additions & 0 deletions mars/log/xlogger_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ void SetAppenderMode(uintptr_t _instance_ptr, TAppenderMode _mode);

void Flush(uintptr_t _instance_ptr, bool _is_sync);

void FlushAll(bool _is_sync);

void SetConsoleLogOpen(uintptr_t _instance_ptr, bool _is_open);

void SetMaxFileSize(uintptr_t _instance_ptr, long _max_file_size);
Expand Down

0 comments on commit 6adbe2c

Please sign in to comment.