From 801ddda073b04c9751bc9e4f935bd102d7741c7b Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Wed, 10 Feb 2016 21:38:10 +0100 Subject: Replace macro argument expansion with more idiomatic recursive template --- src/utility/logger.cc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/utility/logger.cc (limited to 'src/utility/logger.cc') diff --git a/src/utility/logger.cc b/src/utility/logger.cc new file mode 100644 index 0000000..cb5c79a --- /dev/null +++ b/src/utility/logger.cc @@ -0,0 +1,21 @@ +#include "logger.h" + +namespace utility { + +// Forward the contents of a given standard output stream to the log target +// +// While `this->stream_ << stream.rdbuf()` would be more effective it sadly +// does not work with `boost::process::pistream` due to a broken pipe error +// in conjunction with the required `boost::process::capture_stream` context +// flag. +// +void Logger::forward(boost::process::pistream& stream) { + std::lock_guard guard(this->write_mutex_); + + this->stream_ << std::string( + (std::istreambuf_iterator(stream)), + (std::istreambuf_iterator()) + ); +} + +} -- cgit v1.2.3