8#include <userver/logging/log.hpp>
9#include <userver/utils/assert.hpp>
11USERVER_NAMESPACE_BEGIN
20 static void TearDownTestSuite() {
21 Base::TearDownTestSuite();
22 once_used_loggers_.clear();
30 BackUpDefaultLogger();
31 logging::impl::SetDefaultLoggerRef(*new_logger);
35 once_used_loggers_.emplace_back(std::move(new_logger));
40 BackUpDefaultLogger();
44 ~DefaultLoggerFixture() override { RestoreDefaultLogger(); }
47 void BackUpDefaultLogger() {
48 if (!logger_initial_) {
50 level_initial_ =
logging::GetLoggerLevel(*logger_initial_);
54 void RestoreDefaultLogger()
noexcept {
55 if (logger_initial_) {
56 logging::impl::SetDefaultLoggerRef(*logger_initial_);
61 logging::impl::LoggerBase* logger_initial_{
nullptr};
64 static inline std::vector<logging::LoggerPtr> once_used_loggers_;