From 371b61f3eaf6ad8bc35311d906c8d780d1531f8b Mon Sep 17 00:00:00 2001
From: Sean <seanmaas27@gmail.com>
Date: Mon, 27 Oct 2014 17:18:28 -0400
Subject: [PATCH] Add support for disabling log from settings

---
 src/citra/citra.cpp     |  4 ++++
 src/citra/config.cpp    |  5 +++++
 src/citra/config.h      |  1 +
 src/citra/default_ini.h |  3 +++
 src/citra_qt/config.cpp | 14 ++++++++++++++
 src/citra_qt/config.h   |  3 +++
 src/citra_qt/main.cpp   |  5 +++++
 src/core/settings.h     |  2 ++
 8 files changed, 37 insertions(+)

diff --git a/src/citra/citra.cpp b/src/citra/citra.cpp
index 6ac5c5dc5..41b62ac16 100644
--- a/src/citra/citra.cpp
+++ b/src/citra/citra.cpp
@@ -5,6 +5,7 @@
 #include "common/common.h"
 #include "common/log_manager.h"
 
+#include "core/settings.h"
 #include "core/system.h"
 #include "core/core.h"
 #include "core/loader/loader.h"
@@ -22,6 +23,9 @@ int __cdecl main(int argc, char **argv) {
     }
 
     Config config;
+    
+    if (!Settings::values.enable_log)
+        LogManager::Shutdown();
 
     std::string boot_filename = argv[1];
     EmuWindow_GLFW* emu_window = new EmuWindow_GLFW;
diff --git a/src/citra/config.cpp b/src/citra/config.cpp
index 03a0ce606..65edcfc9f 100644
--- a/src/citra/config.cpp
+++ b/src/citra/config.cpp
@@ -59,10 +59,15 @@ void Config::ReadData() {
     Settings::values.use_virtual_sd = glfw_config->GetBoolean("Data Storage", "use_virtual_sd", true);
 }
 
+void Config::ReadMiscellaneous() {
+    Settings::values.enable_log = glfw_config->GetBoolean("Miscellaneous", "enable_log", true);
+}
+
 void Config::Reload() {
     LoadINI(glfw_config, glfw_config_loc.c_str(), DefaultINI::glfw_config_file);
     ReadControls();
     ReadData();
+    ReadMiscellaneous();
 }
 
 Config::~Config() {
diff --git a/src/citra/config.h b/src/citra/config.h
index c4fac2459..63b5978e2 100644
--- a/src/citra/config.h
+++ b/src/citra/config.h
@@ -17,6 +17,7 @@ class Config {
     bool LoadINI(INIReader* config, const char* location, const std::string& default_contents="", bool retry=true);
     void ReadControls();
     void ReadData();
+    void ReadMiscellaneous();
 public:
     Config();
     ~Config();
diff --git a/src/citra/default_ini.h b/src/citra/default_ini.h
index e7e45f4a9..1f0b6cad4 100644
--- a/src/citra/default_ini.h
+++ b/src/citra/default_ini.h
@@ -28,6 +28,9 @@ pad_sright =
 
 [Data Storage]
 use_virtual_sd =
+
+[Miscellaneous]
+enable_log =
 )";
 
 }
diff --git a/src/citra_qt/config.cpp b/src/citra_qt/config.cpp
index 0c4f75a96..0ebc15f13 100644
--- a/src/citra_qt/config.cpp
+++ b/src/citra_qt/config.cpp
@@ -76,14 +76,28 @@ void Config::SaveData() {
     qt_config->endGroup();
 }
 
+void Config::ReadMiscellaneous() {
+    qt_config->beginGroup("Miscellaneous");
+    Settings::values.enable_log = qt_config->value("enable_log", true).toBool();
+    qt_config->endGroup();
+}
+
+void Config::SaveMiscellaneous() {
+    qt_config->beginGroup("Miscellaneous");
+    qt_config->setValue("enable_log", Settings::values.enable_log);
+    qt_config->endGroup();
+}
+
 void Config::Reload() {
     ReadControls();
     ReadData();
+    ReadMiscellaneous();
 }
 
 void Config::Save() {
     SaveControls();
     SaveData();
+    SaveMiscellaneous();
 }
 
 Config::~Config() {
diff --git a/src/citra_qt/config.h b/src/citra_qt/config.h
index 74c9ff11d..979902467 100644
--- a/src/citra_qt/config.h
+++ b/src/citra_qt/config.h
@@ -17,6 +17,9 @@ class Config {
 
     void ReadData();
     void SaveData();
+
+    void ReadMiscellaneous();
+    void SaveMiscellaneous();
 public:
     Config();
     ~Config();
diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp
index bac6a6bb8..c99f92835 100644
--- a/src/citra_qt/main.cpp
+++ b/src/citra_qt/main.cpp
@@ -22,6 +22,7 @@
 #include "debugger/graphics.hxx"
 #include "debugger/graphics_cmdlists.hxx"
 
+#include "core/settings.h"
 #include "core/system.h"
 #include "core/core.h"
 #include "core/loader/loader.h"
@@ -34,8 +35,12 @@
 GMainWindow::GMainWindow()
 {
     LogManager::Init();
+
     Config config;
 
+    if (!Settings::values.enable_log)
+        LogManager::Shutdown();
+
     ui.setupUi(this);
     statusBar()->hide();
 
diff --git a/src/core/settings.h b/src/core/settings.h
index d586e2ef4..77b2f02fc 100644
--- a/src/core/settings.h
+++ b/src/core/settings.h
@@ -26,6 +26,8 @@ struct Values {
     int pad_sright_key;
 
     bool use_virtual_sd;
+
+    bool enable_log;
 } extern values;
 
 }