Skip to content

Commit

Permalink
Fix: flush log when unrecoverable error (#2030)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?

spdlog might not flush the data when unrecoverable error raised. This PR
is to fix it.

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

Signed-off-by: Jin Hai <[email protected]>
  • Loading branch information
JinHai-CN authored Oct 13, 2024
1 parent a84c455 commit 478b2cc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ void Logger::Initialize(const LoggerConfig &config) {
SetLogLevel(config.log_level_);
}

void Logger::Flush() {
infinity_logger->flush();
}

void Logger::Shutdown() {
if (stdout_sinker.get() != nullptr or rotating_file_sinker.get() != nullptr) {
spdlog::shutdown();
Expand Down
1 change: 1 addition & 0 deletions src/main/logger.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public:
Initialize(Config* config_ptr);

static void Initialize(const LoggerConfig &config);
static void Flush();

static void
Shutdown();
Expand Down

0 comments on commit 478b2cc

Please sign in to comment.