diff options
| author | Dan Engelbrecht <[email protected]> | 2023-12-13 08:09:09 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-12-13 14:09:09 +0100 |
| commit | 759a80565c11a329db003b18001b7916eca8b4a5 (patch) | |
| tree | 1797a128ca92357da18cd04772902a3910e34227 | |
| parent | changelog (diff) | |
| download | zen-759a80565c11a329db003b18001b7916eca8b4a5.tar.xz zen-759a80565c11a329db003b18001b7916eca8b4a5.zip | |
fix crash at log exit (#605)
* keep g_FileSink alive until spdlog has shut down
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | src/zenutil/logging.cpp | 12 |
2 files changed, 6 insertions, 7 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 952067a21..0d71e6675 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## - Bugfix: ShutdownLogging code would throw an exception if it was called before everything had been initialised properly +- Bugfix: Reorder shutdown to avoid crash due to late async log messages (spdlog workaround) ## 0.2.36 - Feature: Added xmake task `updatefrontend` which updates the zip file containing the frontend html (`/src/zenserver/frontend/html.zip`) diff --git a/src/zenutil/logging.cpp b/src/zenutil/logging.cpp index 2c1feb08a..5679fada2 100644 --- a/src/zenutil/logging.cpp +++ b/src/zenutil/logging.cpp @@ -196,17 +196,15 @@ FinishInitializeLogging(const LoggingOptions& LogOptions) void ShutdownLogging() { - g_FileSink.reset(); - - if (!g_IsLoggingInitialized) + if (g_IsLoggingInitialized) { - return; + auto DefaultLogger = zen::logging::Default(); + ZEN_LOG_INFO(DefaultLogger, "log ending at {}", zen::DateTime::Now().ToIso8601()); } - auto DefaultLogger = zen::logging::Default(); - ZEN_LOG_INFO(DefaultLogger, "log ending at {}", zen::DateTime::Now().ToIso8601()); - zen::logging::ShutdownLogging(); + + g_FileSink.reset(); } } // namespace zen |