diff options
| author | Stefan Boberg <[email protected]> | 2023-11-06 14:24:31 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-11-06 14:24:31 +0100 |
| commit | 98dfe4e7f8d0ed05f959b5cb0685d144c5462032 (patch) | |
| tree | f69beef950e1596204d4ac15a92180bb56beef4e /src/zenutil/logging.cpp | |
| parent | reduce cachebucket mem (#509) (diff) | |
| download | zen-98dfe4e7f8d0ed05f959b5cb0685d144c5462032.tar.xz zen-98dfe4e7f8d0ed05f959b5cb0685d144c5462032.zip | |
fixed issue where file log sink would get the wrong pattern assigned (#513)
this made the file log emit relative timing instead of an absolute timestamp prefix
Diffstat (limited to 'src/zenutil/logging.cpp')
| -rw-r--r-- | src/zenutil/logging.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/zenutil/logging.cpp b/src/zenutil/logging.cpp index 3cd72eac9..4d8dcbca6 100644 --- a/src/zenutil/logging.cpp +++ b/src/zenutil/logging.cpp @@ -116,18 +116,6 @@ BeginInitializeLogging(const LoggingOptions& LogOptions) } #endif - if (FileSink) - { - if (LogOptions.AbsLogFile.extension() == ".json") - { - FileSink->set_formatter(std::make_unique<logging::json_formatter>(LogOptions.LogId)); - } - else - { - FileSink->set_pattern("[%C-%m-%d.%e %T] [%n] [%l] %v"); - } - } - spdlog::set_error_handler([](const std::string& msg) { if (msg == std::bad_alloc().what()) { @@ -182,6 +170,18 @@ FinishInitializeLogging(const LoggingOptions& LogOptions) spdlog::flush_every(std::chrono::seconds{2}); spdlog::set_formatter(std::make_unique<logging::full_formatter>(LogOptions.LogId, std::chrono::system_clock::now())); + if (g_FileSink) + { + if (LogOptions.AbsLogFile.extension() == ".json") + { + g_FileSink->set_formatter(std::make_unique<logging::json_formatter>(LogOptions.LogId)); + } + else + { + g_FileSink->set_pattern("[%C-%m-%d.%e %T] [%n] [%l] %v"); + } + } + const std::string StartLogTime = zen::DateTime::Now().ToIso8601(); spdlog::apply_all([&](auto Logger) { Logger->info("log starting at {}", StartLogTime); }); |