]> git.tdb.fi Git - builder.git/blobdiff - source/logger.h
Capture value evaluation function by value
[builder.git] / source / logger.h
index c22339f55928270dacadccc02fb2c27302b85b42..3a10f0e89177e10c071b97cd389c79e4d46a1404 100644 (file)
@@ -1,19 +1,34 @@
 #ifndef LOGGER_H_
 #define LOGGER_H_
 
-#include <set>
 #include <string>
+#include <vector>
+#include <msp/strings/format.h>
 
 class Logger
 {
 private:
-       std::set<std::string> enabled_channels;
+       std::vector<std::string> enabled_channels;
 
 public:
        void enable_channel(const std::string &);
        void disable_channel(const std::string &);
+       bool is_channel_enabled(const std::string &) const;
 
        void log(const std::string &, const std::string &) const;
+
+       template<typename... Args>
+       void log(const std::string &, const std::string &, Args &&...) const;
+
+private:
+       void print(const std::string &) const;
 };
 
+template<typename... Args>
+void Logger::log(const std::string &chan, const std::string &fmt, Args &&... args) const
+{
+       if(is_channel_enabled(chan))
+               print(Msp::format(fmt, std::forward<Args>(args)...));
+}
+
 #endif