From 94fc3302c898825d7bc460ad4504577e33f744d9 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Wed, 6 Dec 2023 08:44:46 +0100 Subject: logging configuration via command line options (#589) with these changes it is possible to configure loggers on the command line. For instance: `xmake run zenserver --log-trace=http_requests,http` will configure the system so that the `http_request` and `http` loggers are set to TRACE level --- src/zenutil/logging.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/zenutil/logging.cpp') diff --git a/src/zenutil/logging.cpp b/src/zenutil/logging.cpp index d0a6ac0b4..d82789e42 100644 --- a/src/zenutil/logging.cpp +++ b/src/zenutil/logging.cpp @@ -12,6 +12,7 @@ ZEN_THIRD_PARTY_INCLUDES_END #include #include +#include #include #include #include @@ -152,21 +153,21 @@ BeginInitializeLogging(const LoggingOptions& LogOptions) void FinishInitializeLogging(const LoggingOptions& LogOptions) { - spdlog::level::level_enum LogLevel = spdlog::level::info; + logging::level::LogLevel LogLevel = logging::level::Info; if (LogOptions.IsDebug) { - LogLevel = spdlog::level::debug; + LogLevel = logging::level::Debug; } if (LogOptions.IsTest) { - LogLevel = spdlog::level::trace; + LogLevel = logging::level::Trace; } // Configure all registered loggers according to settings - spdlog::set_level(LogLevel); + logging::RefreshLogLevels(LogLevel); spdlog::flush_on(spdlog::level::err); spdlog::flush_every(std::chrono::seconds{2}); spdlog::set_formatter(std::make_unique(LogOptions.LogId, std::chrono::system_clock::now())); -- cgit v1.2.3