From f18227f429aa3cac0148feccb43dd106fe6d4638 Mon Sep 17 00:00:00 2001
From: Steven Murray <steven.murray@cern.ch>
Date: Wed, 9 Nov 2016 18:05:22 +0100
Subject: [PATCH] Added cta::log::Logger::setLogMask()

---
 common/log/Logger.cpp | 21 ++++++++++++++++++++-
 common/log/Logger.hpp | 17 ++++++++++++++++-
 2 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/common/log/Logger.cpp b/common/log/Logger.cpp
index ca0185d471..5247f576c0 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 b306f482d6..9d53729991 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> &params = 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.
-- 
GitLab