Skip to content

Commit

Permalink
Trigger logs per module - fix #54
Browse files Browse the repository at this point in the history
  • Loading branch information
rbouqueau committed Apr 19, 2016
1 parent 2ff4cf5 commit 6127e1b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions src/lib_modules/core/log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,24 @@

namespace Modules {

struct ILog {
virtual ~ILog() noexcept(false) {}
struct LogCap {
virtual ~LogCap() noexcept(false) {}

template<typename... Arguments>
void log(Level level, const std::string& fmt, Arguments... args) {
Log::msg(level, format("[%s] %s", typeid(*this).name(), format(fmt, args...)));
}

void setLogEnabled(bool enable) {
enabled = enable;
}

bool getLogEnabled() const {
return enabled;
}

private:
bool enabled = true;
};

}
2 changes: 1 addition & 1 deletion src/lib_modules/core/module.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct IModule {
virtual void flush() = 0;
};

class Module : public IModule, public ILog, public IError, public InputCap, public OutputCap {
class Module : public IModule, public IError, public LogCap, public InputCap, public OutputCap {
public:
Module() = default;
virtual ~Module() noexcept(false) {}
Expand Down

0 comments on commit 6127e1b

Please sign in to comment.