blob: 49b7cc11f4cc13dc0d72f292aaff3c3fede27d82 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#ifndef CHANGE_SRC_LOGGER_H_
#define CHANGE_SRC_LOGGER_H_
#include <mutex>
#include <ext/stdio_filebuf.h>
#include <boost/process.hpp>
namespace utility {
class Logger {
public:
Logger(const int target_fd):
buffer_(target_fd, std::ios::out),
stream_(&this->buffer_) { }
template <typename Head>
inline void append(Head&& head) {
this->stream_ << head << std::endl;
}
template <typename Head, typename... Tail>
inline void append(Head&& head, Tail&&... tail) {
this->stream_ << head;
this->append(std::forward<Tail>(tail)...);
}
void forward(boost::process::pistream&);
private:
__gnu_cxx::stdio_filebuf<char> buffer_;
std::ostream stream_;
std::mutex write_mutex_;
};
}
#endif // CHANGE_SRC_LOGGER_H_
|