diff --git a/common/log/Logger.cpp b/common/log/Logger.cpp index ca0185d47195fff29857a6d954be06fbda496ac7..5247f576c06dfc9a3c743c0c44df36f236e04ff6 100644 --- a/common/log/Logger.cpp +++ b/common/log/Logger.cpp @@ -17,6 +17,7 @@ */ #include "common/log/Logger.hpp" +#include "common/log/LogLevel.hpp" #include "common/utils/utils.hpp" #include "common/exception/Exception.hpp" #include <sys/time.h> @@ -307,5 +308,23 @@ std::map<std::string, int> return m; } +//------------------------------------------------------------------------------ +// setLogMask +//------------------------------------------------------------------------------ +void Logger::setLogMask(const std::string logMask) { + try { + setLogMask(toLogLevel(logMask)); + } catch(exception::Exception &ex) { + throw exception::Exception(std::string("Failed to set log mask: ") + ex.getMessage().str()); + } +} + +//------------------------------------------------------------------------------ +// setLogMask +//------------------------------------------------------------------------------ +void Logger::setLogMask(const int logMask) { + m_logMask = logMask; +} + } // namespace log -} // namespace cta \ No newline at end of file +} // namespace cta diff --git a/common/log/Logger.hpp b/common/log/Logger.hpp index b306f482d64ae566ffc326ef0910ec4f44575453..9d537299918b336c48ea5082d0a71c5eeeab6d97 100644 --- a/common/log/Logger.hpp +++ b/common/log/Logger.hpp @@ -21,6 +21,7 @@ #include "common/log/Constants.hpp" #include "common/log/Param.hpp" +#include <atomic> #include <list> #include <map> @@ -123,6 +124,20 @@ public: const int priority, const std::string &msg, const std::list<Param> ¶ms = std::list<Param>()); + + /** + * Sets the log mask. + * + * @param logMask The log mask. + */ + void setLogMask(const std::string logMask); + + /** + * Sets the log mask. + * + * @param logMask The log mask. + */ + void setLogMask(const int logMask); /** * Writes the header of a syslog message to teh specifed output stream. @@ -171,7 +186,7 @@ protected: /** * The log mask. */ - int m_logMask; + std::atomic<int> m_logMask; /** * The maximum message length that the client syslog server can handle.