aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/change_log.cc20
-rw-r--r--src/utility/logger.h27
2 files changed, 25 insertions, 22 deletions
diff --git a/src/change_log.cc b/src/change_log.cc
index 8ff99e4..ae28079 100644
--- a/src/change_log.cc
+++ b/src/change_log.cc
@@ -1,7 +1,3 @@
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-
#include "actual_function.h"
#include "utility/io.h"
@@ -83,6 +79,14 @@ ssize_t writev(int fd, const iovec* iov, int iovcnt) {
return actual::writev(fd, iov, iovcnt);
}
+void* mmap(void* addr, size_t length, int prot, int flags, int fd, off_t offset) {
+ if ( prot & PROT_WRITE ) {
+ track_write(fd);
+ }
+
+ return actual::mmap(addr, length, prot, flags, fd, offset);
+}
+
int rename(const char* old_path, const char* new_path) {
track_rename(old_path, new_path);
@@ -110,11 +114,3 @@ int unlinkat(int dirfd, const char* path, int flags) {
return actual::unlinkat(dirfd, path, flags);
}
-
-void* mmap(void* addr, size_t length, int prot, int flags, int fd, off_t offset) {
- if ( prot & PROT_WRITE ) {
- track_write(fd);
- }
-
- return actual::mmap(addr, length, prot, flags, fd, offset);
-}
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)...);
+ }
+
};
}