test(test_logger): add as_string() method

This commit is contained in:
Marcus Holland-Moritz 2025-08-06 14:21:26 +02:00
parent 1864a235bf
commit fa964a8e87

View File

@ -27,6 +27,7 @@
#include <iostream>
#include <mutex>
#include <optional>
#include <sstream>
#include <string>
#include <vector>
@ -78,6 +79,15 @@ class test_logger : public ::dwarfs::logger {
std::vector<log_entry> const& get_log() const { return log_; }
std::string as_string() const {
std::ostringstream oss;
for (auto const& entry : log_) {
oss << level_char(entry.level) << " [" << entry.loc.file_name() << ":"
<< entry.loc.line() << "] " << entry.output << "\n";
}
return oss.str();
}
bool empty() const { return log_.empty(); }
void clear() { log_.clear(); }