From 6127e1ba23b912df88a1adf1ae3502699123b4a4 Mon Sep 17 00:00:00 2001 From: Romain Bouqueau Date: Tue, 19 Apr 2016 13:33:33 +0200 Subject: [PATCH] Trigger logs per module - fix #54 --- src/lib_modules/core/log.hpp | 15 +++++++++++++-- src/lib_modules/core/module.hpp | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/lib_modules/core/log.hpp b/src/lib_modules/core/log.hpp index e04c037a..826f3fdd 100644 --- a/src/lib_modules/core/log.hpp +++ b/src/lib_modules/core/log.hpp @@ -5,13 +5,24 @@ namespace Modules { -struct ILog { - virtual ~ILog() noexcept(false) {} +struct LogCap { + virtual ~LogCap() noexcept(false) {} template 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; }; } diff --git a/src/lib_modules/core/module.hpp b/src/lib_modules/core/module.hpp index fa1bd418..d63e5c49 100644 --- a/src/lib_modules/core/module.hpp +++ b/src/lib_modules/core/module.hpp @@ -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) {}