mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-18 00:40:30 -04:00
test(test_logger): add as_string()
method
This commit is contained in:
parent
1864a235bf
commit
fa964a8e87
@ -27,6 +27,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -78,6 +79,15 @@ class test_logger : public ::dwarfs::logger {
|
|||||||
|
|
||||||
std::vector<log_entry> const& get_log() const { return log_; }
|
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(); }
|
bool empty() const { return log_.empty(); }
|
||||||
|
|
||||||
void clear() { log_.clear(); }
|
void clear() { log_.clear(); }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user