aboutsummaryrefslogtreecommitdiff
path: root/thirdparty/spdlog/tests/test_backtrace.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2026-03-09 10:50:47 +0100
committerGitHub Enterprise <[email protected]>2026-03-09 10:50:47 +0100
commit19a117889c2db6b817af9458c04c04f324162e75 (patch)
treefbbd0d01c5bf40be90cec88e1d02c6a3c529a2f5 /thirdparty/spdlog/tests/test_backtrace.cpp
parentzenstore bug-fixes from static analysis pass (#815) (diff)
downloadzen-19a117889c2db6b817af9458c04c04f324162e75.tar.xz
zen-19a117889c2db6b817af9458c04c04f324162e75.zip
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
Diffstat (limited to 'thirdparty/spdlog/tests/test_backtrace.cpp')
-rw-r--r--thirdparty/spdlog/tests/test_backtrace.cpp73
1 files changed, 0 insertions, 73 deletions
diff --git a/thirdparty/spdlog/tests/test_backtrace.cpp b/thirdparty/spdlog/tests/test_backtrace.cpp
deleted file mode 100644
index 4d78c0c21..000000000
--- a/thirdparty/spdlog/tests/test_backtrace.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-#include "includes.h"
-#include "test_sink.h"
-#include "spdlog/async.h"
-
-TEST_CASE("bactrace1", "[bactrace]") {
- using spdlog::sinks::test_sink_st;
- auto test_sink = std::make_shared<test_sink_st>();
- size_t backtrace_size = 5;
-
- spdlog::logger logger("test-backtrace", test_sink);
- logger.set_pattern("%v");
- logger.enable_backtrace(backtrace_size);
-
- logger.info("info message");
- for (int i = 0; i < 100; i++) logger.debug("debug message {}", i);
-
- REQUIRE(test_sink->lines().size() == 1);
- REQUIRE(test_sink->lines()[0] == "info message");
-
- logger.dump_backtrace();
- REQUIRE(test_sink->lines().size() == backtrace_size + 3);
- REQUIRE(test_sink->lines()[1] == "****************** Backtrace Start ******************");
- REQUIRE(test_sink->lines()[2] == "debug message 95");
- REQUIRE(test_sink->lines()[3] == "debug message 96");
- REQUIRE(test_sink->lines()[4] == "debug message 97");
- REQUIRE(test_sink->lines()[5] == "debug message 98");
- REQUIRE(test_sink->lines()[6] == "debug message 99");
- REQUIRE(test_sink->lines()[7] == "****************** Backtrace End ********************");
-}
-
-TEST_CASE("bactrace-empty", "[bactrace]") {
- using spdlog::sinks::test_sink_st;
- auto test_sink = std::make_shared<test_sink_st>();
- size_t backtrace_size = 5;
-
- spdlog::logger logger("test-backtrace", test_sink);
- logger.set_pattern("%v");
- logger.enable_backtrace(backtrace_size);
- logger.dump_backtrace();
- REQUIRE(test_sink->lines().size() == 0);
-}
-
-TEST_CASE("bactrace-async", "[bactrace]") {
- using spdlog::sinks::test_sink_mt;
- auto test_sink = std::make_shared<test_sink_mt>();
- using spdlog::details::os::sleep_for_millis;
-
- size_t backtrace_size = 5;
-
- spdlog::init_thread_pool(120, 1);
- auto logger = std::make_shared<spdlog::async_logger>("test-bactrace-async", test_sink,
- spdlog::thread_pool());
- logger->set_pattern("%v");
- logger->enable_backtrace(backtrace_size);
-
- logger->info("info message");
- for (int i = 0; i < 100; i++) logger->debug("debug message {}", i);
-
- sleep_for_millis(100);
- REQUIRE(test_sink->lines().size() == 1);
- REQUIRE(test_sink->lines()[0] == "info message");
-
- logger->dump_backtrace();
- sleep_for_millis(100); // give time for the async dump to complete
- REQUIRE(test_sink->lines().size() == backtrace_size + 3);
- REQUIRE(test_sink->lines()[1] == "****************** Backtrace Start ******************");
- REQUIRE(test_sink->lines()[2] == "debug message 95");
- REQUIRE(test_sink->lines()[3] == "debug message 96");
- REQUIRE(test_sink->lines()[4] == "debug message 97");
- REQUIRE(test_sink->lines()[5] == "debug message 98");
- REQUIRE(test_sink->lines()[6] == "debug message 99");
- REQUIRE(test_sink->lines()[7] == "****************** Backtrace End ********************");
-}