#ifndef CHANGE_SRC_LOGGER_H_ #define CHANGE_SRC_LOGGER_H_ #include #include #include #include namespace utility { class Logger { public: Logger(const int target_fd): buffer_(target_fd, std::ios::out), stream_(&this->buffer_) { } void forward(boost::process::pistream&); template void append(Arguments&&... args) { std::lock_guard guard(this->write_mutex_); this->append_to_stream(std::forward(args)...); } private: __gnu_cxx::stdio_filebuf buffer_; std::ostream stream_; std::mutex write_mutex_; template inline void append_to_stream(Head&& head) { this->stream_ << head << std::endl; } template inline void append_to_stream(Head&& head, Tail&&... tail) { this->stream_ << head; this->append_to_stream(std::forward(tail)...); } }; } #endif // CHANGE_SRC_LOGGER_H_