userver: utest::LogCaptureLogger Class Reference
Loading...
Searching...
No Matches
utest::LogCaptureLogger Class Referencefinal

#include <userver/utest/log_capture_fixture.hpp>

Detailed Description

A mocked logger that stores the log records in memory.

See also
utest::LogCaptureFixture

Definition at line 88 of file log_capture_fixture.hpp.

Public Member Functions

 LogCaptureLogger (logging::Format format=logging::Format::kRaw)
 
logging::LoggerPtr GetLogger () const
 
std::vector< LogRecordGetAll () const
 
std::vector< LogRecordFilter (std::string_view text_substring, utils::span< const std::pair< std::string_view, std::string_view > > tag_substrings={}) const
 
std::vector< LogRecordFilter (utils::function_ref< bool(const LogRecord &)> predicate) const
 
void Clear () noexcept
 Discards the collected logs.
 
template<typename T >
std::string ToStringViaLogging (const T &value)
 Logs value as-if using LOG_*, then extracts the log text.
 

Member Function Documentation

◆ Filter() [1/2]

std::vector< LogRecord > utest::LogCaptureLogger::Filter ( std::string_view text_substring,
utils::span< const std::pair< std::string_view, std::string_view > > tag_substrings = {} ) const
Returns
logs filtered by (optional) text substring and (optional) tags substrings.
See also
GetSingleLog

◆ Filter() [2/2]

std::vector< LogRecord > utest::LogCaptureLogger::Filter ( utils::function_ref< bool(const LogRecord &)> predicate) const
Returns
logs filtered by an arbitrary predicate.
See also
GetSingleLog

◆ GetAll()

std::vector< LogRecord > utest::LogCaptureLogger::GetAll ( ) const
Returns
all collected logs.
See also
GetSingleLog

◆ GetLogger()

logging::LoggerPtr utest::LogCaptureLogger::GetLogger ( ) const
Returns
the mocked logger.

◆ ToStringViaLogging()

template<typename T >
std::string utest::LogCaptureLogger::ToStringViaLogging ( const T & value)
inline

Logs value as-if using LOG_*, then extracts the log text.

Definition at line 117 of file log_capture_fixture.hpp.


The documentation for this class was generated from the following file: