aboutsummaryrefslogtreecommitdiff
path: root/src/zenutil/logging.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2025-03-11 09:58:07 +0100
committerGitHub Enterprise <[email protected]>2025-03-11 09:58:07 +0100
commit90db3ced033d4e06da2739e5d97cdeff2b0ba3b9 (patch)
tree8c1375cc1217886ef51f8fd0c3460b274b82527c /src/zenutil/logging.cpp
parentpick up existing cache (#299) (diff)
downloadzen-90db3ced033d4e06da2739e5d97cdeff2b0ba3b9.tar.xz
zen-90db3ced033d4e06da2739e5d97cdeff2b0ba3b9.zip
Build command tweaks (#301)
- Improvement: Don't chunk up .mp4 files as they generally won't benefit from deduplication or partial in-place-updates - Improvement: Emit build name to console output when downloading a build - Improvement: Added some debug logging - Bugfix: Logging setup would previously not function correctly when not logging to file
Diffstat (limited to 'src/zenutil/logging.cpp')
-rw-r--r--src/zenutil/logging.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/zenutil/logging.cpp b/src/zenutil/logging.cpp
index 0444fa2c4..762b75a59 100644
--- a/src/zenutil/logging.cpp
+++ b/src/zenutil/logging.cpp
@@ -49,7 +49,7 @@ BeginInitializeLogging(const LoggingOptions& LogOptions)
zen::logging::InitializeLogging();
zen::logging::EnableVTMode();
- bool IsAsync = true;
+ bool IsAsync = LogOptions.AllowAsync;
if (LogOptions.IsDebug)
{
@@ -181,7 +181,7 @@ FinishInitializeLogging(const LoggingOptions& LogOptions)
LogLevel = logging::level::Debug;
}
- if (LogOptions.IsTest)
+ if (LogOptions.IsTest || LogOptions.IsVerbose)
{
LogLevel = logging::level::Trace;
}
@@ -194,18 +194,21 @@ 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 (LogOptions.AbsLogFile.extension() == ".json")
- {
- g_FileSink->set_formatter(std::make_unique<logging::json_formatter>(LogOptions.LogId));
- }
- else
+ if (g_FileSink)
{
- g_FileSink->set_formatter(std::make_unique<logging::full_formatter>(LogOptions.LogId)); // this will have a date prefix
- }
+ 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();
+ const std::string StartLogTime = zen::DateTime::Now().ToIso8601();
- spdlog::apply_all([&](auto Logger) { Logger->info("log starting at {}", StartLogTime); });
+ spdlog::apply_all([&](auto Logger) { Logger->info("log starting at {}", StartLogTime); });
+ }
g_IsLoggingInitialized = true;
}
@@ -213,7 +216,7 @@ FinishInitializeLogging(const LoggingOptions& LogOptions)
void
ShutdownLogging()
{
- if (g_IsLoggingInitialized)
+ if (g_IsLoggingInitialized && g_FileSink)
{
auto DefaultLogger = zen::logging::Default();
ZEN_LOG_INFO(DefaultLogger, "log ending at {}", zen::DateTime::Now().ToIso8601());