From eda80187286db32eb6f6dd8255a31226f33a3121 Mon Sep 17 00:00:00 2001
From: Martyn Gigg <martyn.gigg@gmail.com>
Date: Fri, 24 Nov 2017 15:40:11 +0000
Subject: [PATCH] Add option to quietly change the logging level

Refs #21251
---
 Framework/Kernel/inc/MantidKernel/ConfigService.h |  2 +-
 Framework/Kernel/src/ConfigService.cpp            | 11 +++++++----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/Framework/Kernel/inc/MantidKernel/ConfigService.h b/Framework/Kernel/inc/MantidKernel/ConfigService.h
index bf14c00ff53..e22ad3433e9 100644
--- a/Framework/Kernel/inc/MantidKernel/ConfigService.h
+++ b/Framework/Kernel/inc/MantidKernel/ConfigService.h
@@ -240,7 +240,7 @@ public:
   void setConsoleLogLevel(int logLevel);
   /// Sets the log level priority for the selected Filter log channel
   void setFilterChannelLogLevel(const std::string &filterChannelName,
-                                int logLevel);
+                                int logLevel, bool quiet = false);
 
   /// Look for an instrument
   const InstrumentInfo &
diff --git a/Framework/Kernel/src/ConfigService.cpp b/Framework/Kernel/src/ConfigService.cpp
index 7510ee3036c..b2092a303b8 100644
--- a/Framework/Kernel/src/ConfigService.cpp
+++ b/Framework/Kernel/src/ConfigService.cpp
@@ -2036,11 +2036,12 @@ void ConfigServiceImpl::setConsoleLogLevel(int logLevel) {
 /** Sets the Log level for a filter channel
 * @param filterChannelName the channel name of the filter channel to change
 * @param logLevel the integer value of the log level to set, 1=Critical, 7=Debug
+* @param quiet If true then no message regarding the level change is emitted
 * @throws std::invalid_argument if the channel name is incorrect or it is not a
 * filterChannel
 */
 void ConfigServiceImpl::setFilterChannelLogLevel(
-    const std::string &filterChannelName, int logLevel) {
+    const std::string &filterChannelName, int logLevel, bool quiet) {
   Poco::Channel *channel = nullptr;
   try {
     channel = Poco::LoggingRegistry::defaultRegistry().channelForName(
@@ -2059,9 +2060,11 @@ void ConfigServiceImpl::setFilterChannelLogLevel(
     if (rootLevel != lowestLogLevel) {
       Mantid::Kernel::Logger::setLevelForAll(lowestLogLevel);
     }
-    g_log.log(filterChannelName + " log channel set to " +
-                  Logger::PriorityNames[logLevel] + " priority",
-              static_cast<Logger::Priority>(logLevel));
+    if (!quiet) {
+      g_log.log(filterChannelName + " log channel set to " +
+                    Logger::PriorityNames[logLevel] + " priority",
+                static_cast<Logger::Priority>(logLevel));
+    }
   } else {
     throw std::invalid_argument(filterChannelName +
                                 " was not a filter channel");
-- 
GitLab