Skip to content

Commit 33bc101

Browse files
committed
xlog api
2 parents c6a1461 + 248ea3b commit 33bc101

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

mars/log/src/xlogger_interface.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,17 @@ void Flush(uintptr_t _instance_ptr, bool _is_sync) {
144144
}
145145
}
146146

147+
void FlushAll(bool _is_sync) {
148+
_is_sync ? appender_flush_sync() : appender_flush();
149+
ScopedLock lock(sg_mutex);
150+
// loop through all categories
151+
for (auto it = sg_map.begin(); it != sg_map.end(); ++it) {
152+
XloggerCategory* category = it->second;
153+
XloggerAppender* appender = reinterpret_cast<XloggerAppender*>(category->GetAppender());
154+
_is_sync ? appender->FlushSync() : appender->Flush();
155+
}
156+
}
157+
147158
void SetConsoleLogOpen(uintptr_t _instance_ptr, bool _is_open) {
148159
if (0 == _instance_ptr) {
149160
appender_set_console_log(_is_open);

mars/log/xlogger_interface.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ void SetAppenderMode(uintptr_t _instance_ptr, TAppenderMode _mode);
5656

5757
void Flush(uintptr_t _instance_ptr, bool _is_sync);
5858

59+
void FlushAll(bool _is_sync);
60+
5961
void SetConsoleLogOpen(uintptr_t _instance_ptr, bool _is_open);
6062

6163
void SetMaxFileSize(uintptr_t _instance_ptr, long _max_file_size);

0 commit comments

Comments
 (0)