Browse Source

Add CBasicLogConfigurator::deconfigure method to clear the global log targets

Victor Luchits 6 years ago
parent
commit
0fe71b7c44
2 changed files with 11 additions and 0 deletions
  1. 7 0
      lib/logging/CBasicLogConfigurator.cpp
  2. 4 0
      lib/logging/CBasicLogConfigurator.h

+ 7 - 0
lib/logging/CBasicLogConfigurator.cpp

@@ -140,3 +140,10 @@ EConsoleTextColor::EConsoleTextColor CBasicLogConfigurator::getConsoleColor(cons
 	else
 		throw std::runtime_error("Color " + colorName + " unknown.");
 }
+
+void CBasicLogConfigurator::deconfigure() {
+	auto l = CLogger::getGlobalLogger();
+	if(l != nullptr) {
+		l->clearTargets();
+	}
+}

+ 4 - 0
lib/logging/CBasicLogConfigurator.h

@@ -29,6 +29,10 @@ public:
 
 	/// Configures a default logging system by adding the console target and the file target to the global logger.
 	void configureDefault();
+
+	/// Removes all targets from the global logger.
+	void deconfigure();
+
 private:
 	// Gets ELogLevel enum from string. (Should be moved to CLogger as a separate function?)
 	// Throws: std::runtime_error