diff options
| author | Dan Engelbrecht <[email protected]> | 2023-12-18 09:54:06 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-12-18 15:54:06 +0100 |
| commit | 713bb99a0603667ec53c74fd4799f1841a4c7f70 (patch) | |
| tree | 5fbf7594720f8aa2c61cedd5da4a34ade169642b | |
| parent | 0.2.38-pre1 (diff) | |
| download | zen-713bb99a0603667ec53c74fd4799f1841a4c7f70.tar.xz zen-713bb99a0603667ec53c74fd4799f1841a4c7f70.zip | |
Make sure we initialize the pattern of FileSink before it is added as a usable logger (#615)
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | src/zenutil/logging.cpp | 20 |
2 files changed, 9 insertions, 12 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 89f977afb..b7503d0b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## - Bugfix: Cache RPC recording would drop data when it reached 4GB of inline chunk data in a segment +- Bugfix: Make sure we initialize the pattern of FileSink before it is added as a usable logger - Improvement: Cache RPC replay can now process partial recordings by recovering metadata from available files - Improvement: Cache RPC recording now limits duration of individual segments to 1h - Improvement: Made RPC replay command line parsing more robust by ensuring at least one processing thread is in use diff --git a/src/zenutil/logging.cpp b/src/zenutil/logging.cpp index 5679fada2..64230ea81 100644 --- a/src/zenutil/logging.cpp +++ b/src/zenutil/logging.cpp @@ -84,6 +84,14 @@ BeginInitializeLogging(const LoggingOptions& LogOptions) /* max size */ 128 * 1024 * 1024, /* max files */ 16, /* rotate on open */ true); + if (LogOptions.AbsLogFile.extension() == ".json") + { + FileSink->set_formatter(std::make_unique<logging::json_formatter>(LogOptions.LogId)); + } + else + { + FileSink->set_formatter(std::make_unique<logging::full_formatter>(LogOptions.LogId)); // this will have a date prefix + } } std::set_terminate([]() { ZEN_CRITICAL("Program exited abnormally via std::terminate()"); }); @@ -174,18 +182,6 @@ FinishInitializeLogging(const LoggingOptions& LogOptions) spdlog::set_formatter( std::make_unique<logging::full_formatter>(LogOptions.LogId, std::chrono::system_clock::now())); // default to duration prefix - if (g_FileSink) - { - if (LogOptions.AbsLogFile.extension() == ".json") - { - g_FileSink->set_formatter(std::make_unique<logging::json_formatter>(LogOptions.LogId)); - } - else - { - g_FileSink->set_formatter(std::make_unique<logging::full_formatter>(LogOptions.LogId)); // this will have a date prefix - } - } - const std::string StartLogTime = zen::DateTime::Now().ToIso8601(); spdlog::apply_all([&](auto Logger) { Logger->info("log starting at {}", StartLogTime); }); |