From 19a117889c2db6b817af9458c04c04f324162e75 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Mon, 9 Mar 2026 10:50:47 +0100 Subject: Eliminate spdlog dependency (#773) Removes the vendored spdlog library (~12,000 lines) and replaces it with a purpose-built logging system in zencore (~1,800 lines). The new implementation provides the same functionality with fewer abstractions, no shared_ptr overhead, and full control over the logging pipeline. ### What changed **New logging core in zencore/logging/:** - LogMessage, Formatter, Sink, Logger, Registry - core abstractions matching spdlog's model but simplified - AnsiColorStdoutSink - ANSI color console output (replaces spdlog stdout_color_sink) - MsvcSink - OutputDebugString on Windows (replaces spdlog msvc_sink) - AsyncSink - async logging via BlockingQueue worker thread (replaces spdlog async_logger) - NullSink, MessageOnlyFormatter - utility types - Thread-safe timestamp caching in formatters using RwLock **Moved to zenutil/logging/:** - FullFormatter - full log formatting with timestamp, logger name, level, source location, multiline alignment - JsonFormatter - structured JSON log output - RotatingFileSink - rotating file sink with atomic size tracking **API changes:** - Log levels are now an enum (LogLevel) instead of int, eliminating the zen::logging::level namespace - LoggerRef no longer wraps shared_ptr - it holds a raw pointer with the registry owning lifetime - Logger error handler is wired through Registry and propagated to all loggers on registration - Logger::Log() now populates ThreadId on every message **Cleanup:** - Deleted thirdparty/spdlog/ entirely (110+ files) - Deleted full_test_formatter (was ~80% duplicate of FullFormatter) - Renamed snake_case classes to PascalCase (full_formatter -> FullFormatter, json_formatter -> JsonFormatter, sentry_sink -> SentrySink) - Removed spdlog from xmake dependency graph ### Build / test impact - zencore no longer depends on spdlog - zenutil and zenvfs xmake.lua updated to drop spdlog dep - zentelemetry xmake.lua updated to drop spdlog dep - All existing tests pass, no test changes required beyond formatter class renames --- thirdparty/spdlog/tests/test_custom_callbacks.cpp | 37 ----------------------- 1 file changed, 37 deletions(-) delete mode 100644 thirdparty/spdlog/tests/test_custom_callbacks.cpp (limited to 'thirdparty/spdlog/tests/test_custom_callbacks.cpp') diff --git a/thirdparty/spdlog/tests/test_custom_callbacks.cpp b/thirdparty/spdlog/tests/test_custom_callbacks.cpp deleted file mode 100644 index f14572115..000000000 --- a/thirdparty/spdlog/tests/test_custom_callbacks.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This content is released under the MIT License as specified in - * https://raw.githubusercontent.com/gabime/spdlog/master/LICENSE - */ -#include "includes.h" -#include "test_sink.h" -#include "spdlog/sinks/callback_sink.h" -#include "spdlog/async.h" -#include "spdlog/common.h" - -TEST_CASE("custom_callback_logger", "[custom_callback_logger]") { - std::vector lines; - spdlog::pattern_formatter formatter; - auto callback_logger = - std::make_shared([&](const spdlog::details::log_msg &msg) { - spdlog::memory_buf_t formatted; - formatter.format(msg, formatted); - auto eol_len = strlen(spdlog::details::os::default_eol); - using diff_t = - typename std::iterator_traits::difference_type; - lines.emplace_back(formatted.begin(), formatted.end() - static_cast(eol_len)); - }); - std::shared_ptr test_sink(new spdlog::sinks::test_sink_st); - - spdlog::logger logger("test-callback", {callback_logger, test_sink}); - - logger.info("test message 1"); - logger.info("test message 2"); - logger.info("test message 3"); - - std::vector ref_lines = test_sink->lines(); - - REQUIRE(lines[0] == ref_lines[0]); - REQUIRE(lines[1] == ref_lines[1]); - REQUIRE(lines[2] == ref_lines[2]); - spdlog::drop_all(); -} -- cgit v1.2.3