aboutsummaryrefslogtreecommitdiff
path: root/src/zenutil/logging.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zenutil/logging.cpp')
-rw-r--r--src/zenutil/logging.cpp20
1 files changed, 8 insertions, 12 deletions
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); });