diff options
Diffstat (limited to 'indra/test/namedtempfile.h')
-rw-r--r-- | indra/test/namedtempfile.h | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/indra/test/namedtempfile.h b/indra/test/namedtempfile.h index 3a994ae798..ad14cebbd1 100644 --- a/indra/test/namedtempfile.h +++ b/indra/test/namedtempfile.h @@ -67,14 +67,31 @@ public: std::string getName() const { return mPath.string(); } - void peep() + template <typename CALLABLE> + void peep_via(CALLABLE&& callable) const { - std::cout << "File '" << mPath << "' contains:\n"; + std::forward<CALLABLE>(callable)(stringize("File '", mPath, "' contains:")); boost::filesystem::ifstream reader(mPath, std::ios::binary); std::string line; while (std::getline(reader, line)) - std::cout << line << '\n'; - std::cout << "---\n"; + std::forward<CALLABLE>(callable)(line); + std::forward<CALLABLE>(callable)("---"); + } + + void peep_log() const + { + peep_via([](const std::string& line){ LL_DEBUGS() << line << LL_ENDL; }); + } + + void peep(std::ostream& out=std::cout) const + { + peep_via([&out](const std::string& line){ out << line << '\n'; }); + } + + friend std::ostream& operator<<(std::ostream& out, const NamedTempFile& self) + { + self.peep(out); + return out; } static boost::filesystem::path temp_path(const std::string_view& pfx="", |