From 759a80565c11a329db003b18001b7916eca8b4a5 Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Wed, 13 Dec 2023 08:09:09 -0500 Subject: fix crash at log exit (#605) * keep g_FileSink alive until spdlog has shut down --- src/zenutil/logging.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/zenutil/logging.cpp') 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 -- cgit v1.2.3