aboutsummaryrefslogtreecommitdiff
path: root/src/utility
diff options
context:
space:
mode:
authorAdrian Kummerlaender2016-02-07 22:18:10 +0100
committerAdrian Kummerlaender2016-02-07 22:18:10 +0100
commit77ca603e933af25088057dc5e26cfda84bde7147 (patch)
treefbe79d477be038f84d955ecf52f71ea01e687821 /src/utility
parentbfa7c9e7ea1f818482a4205a500e87fb9d8a8ec3 (diff)
downloadchange-77ca603e933af25088057dc5e26cfda84bde7147.tar
change-77ca603e933af25088057dc5e26cfda84bde7147.tar.gz
change-77ca603e933af25088057dc5e26cfda84bde7147.tar.bz2
change-77ca603e933af25088057dc5e26cfda84bde7147.tar.lz
change-77ca603e933af25088057dc5e26cfda84bde7147.tar.xz
change-77ca603e933af25088057dc5e26cfda84bde7147.tar.zst
change-77ca603e933af25088057dc5e26cfda84bde7147.zip
Increase log message generation readability
Diffstat (limited to 'src/utility')
-rw-r--r--src/utility/logger.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/utility/logger.h b/src/utility/logger.h
index 30a6b44..6fd6613 100644
--- a/src/utility/logger.h
+++ b/src/utility/logger.h
@@ -10,15 +10,21 @@
namespace utility {
class Logger {
+ #define FOR_EACH_ARGUMENT(...)\
+ auto&& tmp = { (__VA_ARGS__, 0)... }; (void) tmp;
+
public:
Logger(const int target_fd):
buffer_(target_fd, std::ios::out),
stream_(&this->buffer_) { }
- void append(const std::string& msg) {
+ template <typename... Args>
+ void append(const Args&... args) {
std::lock_guard<std::mutex> guard(this->write_mutex_);
- this->stream_ << msg << std::endl;
+ FOR_EACH_ARGUMENT(this->stream_ << args);
+
+ this->stream_ << std::endl;
}
// Forward the contents of a given standard output stream to the log target
@@ -42,6 +48,7 @@ class Logger {
std::ostream stream_;
std::mutex write_mutex_;
+ #undef FOR_EACH_ARGUMENT
};
}