Summary
Some tests replace the global spdlog default logger with an ostream_sink_mt that references a local std::ostringstream. If the test does not restore the previous default logger before the stream is destroyed, later spdlog calls can access a destroyed stream.
Required changes
- Add a common test-only ostream-logging utility for tests that need to inspect log output.
- The utility must save the existing
spdlog::default_logger() before it installs a test logger.
- The utility must restore the saved default logger with scope-bound cleanup before its
std::ostringstream is destroyed.
- Update tests that need ostream logging to use this common utility. Do not re-implement local logger-installation helpers in each test.
Rationale
spdlog::set_default_logger(...) changes global process state. A shared scoped utility prevents dangling ostream_sink_mt stream references and gives all tests the same cleanup behavior.
Affected areas
- Test logging helpers or test support module.
test/accumulator_test.cpp (use_ostream_logger).
- Other tests that replace the global
spdlog default logger.
Acceptance criteria
- A reusable scoped ostream-logging utility exists for test code.
- The utility restores the prior default logger before its backing stream is destroyed.
test/accumulator_test.cpp uses the common utility.
- Other tests that require ostream logging use the same utility instead of duplicate local implementations.
Backlinks
Summary
Some tests replace the global
spdlogdefault logger with anostream_sink_mtthat references a localstd::ostringstream. If the test does not restore the previous default logger before the stream is destroyed, laterspdlogcalls can access a destroyed stream.Required changes
spdlog::default_logger()before it installs a test logger.std::ostringstreamis destroyed.Rationale
spdlog::set_default_logger(...)changes global process state. A shared scoped utility prevents danglingostream_sink_mtstream references and gives all tests the same cleanup behavior.Affected areas
test/accumulator_test.cpp(use_ostream_logger).spdlogdefault logger.Acceptance criteria
test/accumulator_test.cppuses the common utility.Backlinks