]> git.tdb.fi Git - builder.git/blob - source/lib/logger.h
Add visibility decorations to the library and plugins
[builder.git] / source / lib / logger.h
1 #ifndef LOGGER_H_
2 #define LOGGER_H_
3
4 #include <string>
5 #include <vector>
6 #include <msp/strings/format.h>
7 #include "libbuilder_api.h"
8
9 class LIBBUILDER_API Logger
10 {
11 private:
12         std::vector<std::string> enabled_channels;
13
14 public:
15         void enable_channel(const std::string &);
16         void disable_channel(const std::string &);
17         bool is_channel_enabled(const std::string &) const;
18
19         void log(const std::string &, const std::string &) const;
20
21         template<typename... Args>
22         void log(const std::string &, const std::string &, Args &&...) const;
23
24 private:
25         void print(const std::string &) const;
26 };
27
28 template<typename... Args>
29 void Logger::log(const std::string &chan, const std::string &fmt, Args &&... args) const
30 {
31         if(is_channel_enabled(chan))
32                 print(Msp::format(fmt, std::forward<Args>(args)...));
33 }
34
35 #endif