diff options
| author | Stefan Boberg <[email protected]> | 2023-12-12 12:13:56 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-12-12 12:13:56 +0100 |
| commit | 4e427d6cdd6a164aa0e63f7514b9ea381e639a17 (patch) | |
| tree | ec067e61ba3b684372a496267b15d2d9a0e4ea18 | |
| parent | 0.2.36 (diff) | |
| download | zen-4e427d6cdd6a164aa0e63f7514b9ea381e639a17.tar.xz zen-4e427d6cdd6a164aa0e63f7514b9ea381e639a17.zip | |
premature logging shutdown fix (#603)v0.2.36
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | src/zenutil/logging.cpp | 9 |
2 files changed, 10 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index cf51e9f19..e188b211d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - Bugfix: Shut down thread pools earlier so worker threads have a chance to terminate before main thread calls `atexit()` - Bugfix: Use correct lookup index when checking for memcached buffer when finding references in diskcache GC - Bugfix: CasContainerStrategy::ReadIndexFile issue could cause CAS items to not be found after a shutdown/restart cycle +- Bugfix: ShutdownLogging code would throw an exception if it was called before everything had been initialised properly - Bugfix: Make sure we don't hold the namespace bucket lock when we create buckets to avoid deadlock - Bugfix: Make sure that PathFromHandle don't hide true error when throwing exceptions - Bugfix: Allow attachments that contains a raw size of zero diff --git a/src/zenutil/logging.cpp b/src/zenutil/logging.cpp index fedfdc7e8..2c1feb08a 100644 --- a/src/zenutil/logging.cpp +++ b/src/zenutil/logging.cpp @@ -23,6 +23,7 @@ ZEN_THIRD_PARTY_INCLUDES_END namespace zen { +static bool g_IsLoggingInitialized; spdlog::sink_ptr g_FileSink; spdlog::sink_ptr @@ -188,6 +189,8 @@ FinishInitializeLogging(const LoggingOptions& LogOptions) const std::string StartLogTime = zen::DateTime::Now().ToIso8601(); spdlog::apply_all([&](auto Logger) { Logger->info("log starting at {}", StartLogTime); }); + + g_IsLoggingInitialized = true; } void @@ -195,8 +198,14 @@ ShutdownLogging() { g_FileSink.reset(); + if (!g_IsLoggingInitialized) + { + return; + } + auto DefaultLogger = zen::logging::Default(); ZEN_LOG_INFO(DefaultLogger, "log ending at {}", zen::DateTime::Now().ToIso8601()); + zen::logging::ShutdownLogging(); } |