13#include <gtest/gtest.h>
15#include <userver/logging/impl/logger_base.hpp>
16#include <userver/logging/level.hpp>
17#include <userver/logging/log.hpp>
18#include <userver/utest/default_logger_fixture.hpp>
19#include <userver/utils/function_ref.hpp>
20#include <userver/utils/impl/internal_tag.hpp>
21#include <userver/utils/impl/source_location.hpp>
22#include <userver/utils/not_null.hpp>
23#include <userver/utils/span.hpp>
25USERVER_NAMESPACE_BEGIN
36class LogRecord
final {
44 const std::string&
GetTag(std::string_view key)
const;
66 std::vector<std::pair<std::string, std::string>> tags_;
69std::ostream& operator<<(std::ostream&,
const LogRecord& data);
71std::ostream& operator<<(std::ostream&,
const std::vector<LogRecord>& data);
74class NotSingleLogError
final :
public std::runtime_error {
76 using std::runtime_error::runtime_error;
82 utils::span<
const LogRecord> log,
88class LogCaptureLogger
final {
115 template <
typename T>
119 auto text = GetSingleLog(GetAll()).GetText();
125 utils::SharedRef<impl::ToStringLogger> logger_;
131template <
typename Base = ::testing::Test>
134 LogCaptureFixture() { DefaultLoggerFixture<Base>::SetDefaultLogger(logger_.GetLogger()); }
136 LogCaptureLogger& GetLogCapture() {
return logger_; }
139 LogCaptureLogger logger_;