aboutsummaryrefslogtreecommitdiff
path: root/src/utility
diff options
context:
space:
mode:
Diffstat (limited to 'src/utility')
-rw-r--r--src/utility/logger.h27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/utility/logger.h b/src/utility/logger.h
index 49b7cc1..0dd88a6 100644
--- a/src/utility/logger.h
+++ b/src/utility/logger.h
@@ -15,25 +15,32 @@ class Logger {
buffer_(target_fd, std::ios::out),
stream_(&this->buffer_) { }
- template <typename Head>
- inline void append(Head&& head) {
- this->stream_ << head << std::endl;
- }
+ void forward(boost::process::pistream&);
- template <typename Head, typename... Tail>
- inline void append(Head&& head, Tail&&... tail) {
- this->stream_ << head;
+ template <typename... Arguments>
+ void append(Arguments&&... args) {
+ std::lock_guard<std::mutex> guard(this->write_mutex_);
- this->append(std::forward<Tail>(tail)...);
+ this->append_to_stream(std::forward<Arguments>(args)...);
}
- void forward(boost::process::pistream&);
-
private:
__gnu_cxx::stdio_filebuf<char> buffer_;
std::ostream stream_;
std::mutex write_mutex_;
+ template <typename Head>
+ inline void append_to_stream(Head&& head) {
+ this->stream_ << head << std::endl;
+ }
+
+ template <typename Head, typename... Tail>
+ inline void append_to_stream(Head&& head, Tail&&... tail) {
+ this->stream_ << head;
+
+ this->append_to_stream(std::forward<Tail>(tail)...);
+ }
+
};
}