feat: Do not print critical errors in stdout (#2468)

This commit is contained in:
Ayaz Salikhov
2025-08-21 15:33:01 +01:00
committed by GitHub
parent e2fbf56277
commit 3681ef4e41
5 changed files with 54 additions and 14 deletions

View File

@@ -22,6 +22,7 @@
#include "util/log/Logger.hpp"
#include <spdlog/common.h>
#include <spdlog/pattern_formatter.h>
#include <spdlog/sinks/ostream_sink.h>
#include <spdlog/spdlog.h>
@@ -35,6 +36,7 @@ LoggerFixture::LoggerFixture()
// Create ostream sink for testing
auto ostreamSink = std::make_shared<spdlog::sinks::ostream_sink_mt>(stream_);
ostreamSink->set_formatter(std::make_unique<spdlog::pattern_formatter>("%^%3!l:%n%$ - %v"));
// Create loggers for each channel
std::ranges::for_each(util::Logger::kCHANNELS, [&ostreamSink](char const* channel) {
@@ -50,8 +52,6 @@ LoggerFixture::LoggerFixture()
spdlog::register_logger(traceLogger);
spdlog::set_default_logger(spdlog::get("General"));
spdlog::set_pattern("%^%3!l:%n%$ - %v");
}
NoLoggerFixture::NoLoggerFixture()

View File

@@ -32,6 +32,7 @@
#include <fmt/format.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <spdlog/pattern_formatter.h>
#include <spdlog/sinks/ostream_sink.h>
#include <spdlog/spdlog.h>
@@ -84,6 +85,7 @@ protected:
replaceSinks()
{
auto ostreamSink = std::make_shared<spdlog::sinks::ostream_sink_mt>(stream_);
ostreamSink->set_formatter(std::make_unique<spdlog::pattern_formatter>("%^%3!l:%n%$ - %v"));
for (auto const& channel : Logger::kCHANNELS) {
auto logger = spdlog::get(channel);
@@ -93,8 +95,6 @@ protected:
logger->sinks().clear();
logger->sinks().push_back(ostreamSink);
}
spdlog::set_pattern("%^%3!l:%n%$ - %v");
}
private: