From 588bafdfad0aa5b4251e80894258f50f48c2fe70 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Wed, 29 Nov 2023 12:22:49 +0100 Subject: fixed file logger pattern (#579) previously, the millisecond part was inexplicably logged after the date, not the time. --- src/zenutil/logging.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/zenutil/logging.cpp') diff --git a/src/zenutil/logging.cpp b/src/zenutil/logging.cpp index 512c7901c..d0a6ac0b4 100644 --- a/src/zenutil/logging.cpp +++ b/src/zenutil/logging.cpp @@ -179,7 +179,7 @@ FinishInitializeLogging(const LoggingOptions& LogOptions) } else { - g_FileSink->set_pattern("[%C-%m-%d.%e %T] [%n] [%l] %v"); + g_FileSink->set_pattern("[%C-%m-%d %T.%e] [%n] [%l] %v"); } } -- cgit v1.2.3 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 From 3849faabb060d58fd7e056aa01445cf1ae3ab0f9 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Mon, 11 Dec 2023 11:00:05 +0100 Subject: multi-line logging improvements (#597) * added ZEN_SCOPED_WARN and implemented multi-line logging * changed so file log also uses `fullformatter` for consistency and to get the multi-line support across the board --- src/zenutil/logging.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/zenutil/logging.cpp') diff --git a/src/zenutil/logging.cpp b/src/zenutil/logging.cpp index d82789e42..fedfdc7e8 100644 --- a/src/zenutil/logging.cpp +++ b/src/zenutil/logging.cpp @@ -170,7 +170,8 @@ FinishInitializeLogging(const LoggingOptions& LogOptions) 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())); + spdlog::set_formatter( + std::make_unique(LogOptions.LogId, std::chrono::system_clock::now())); // default to duration prefix if (g_FileSink) { @@ -180,7 +181,7 @@ FinishInitializeLogging(const LoggingOptions& LogOptions) } else { - g_FileSink->set_pattern("[%C-%m-%d %T.%e] [%n] [%l] %v"); + g_FileSink->set_formatter(std::make_unique(LogOptions.LogId)); // this will have a date prefix } } -- cgit v1.2.3