diff options
| author | 2021-08-24 01:32:38 -0400 | |
|---|---|---|
| committer | 2021-08-24 01:32:38 -0400 | |
| commit | 84b4ac572954c3fbf114a877f00a12020d3b31f8 (patch) | |
| tree | 4b257caf10eb6e7dfd2113671a7ebdcd845dcf3b /src/common/logging/backend.cpp | |
| parent | Merge pull request #6878 from BreadFish64/optimize-GetHostThreadID (diff) | |
| download | yuzu-84b4ac572954c3fbf114a877f00a12020d3b31f8.tar.gz yuzu-84b4ac572954c3fbf114a877f00a12020d3b31f8.tar.xz yuzu-84b4ac572954c3fbf114a877f00a12020d3b31f8.zip | |
logging: Fix log filter during initialization
The log filter was being ignored on initialization due to the logging instance being initialized before the config instance, so the log filter was set to its default value.
This fixes that oversight, along with using descriptive exceptions instead of abort() calls.
Diffstat (limited to 'src/common/logging/backend.cpp')
| -rw-r--r-- | src/common/logging/backend.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index 13edda9c9..949384fd3 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #include <atomic> | 5 | #include <atomic> |
| 6 | #include <chrono> | 6 | #include <chrono> |
| 7 | #include <climits> | 7 | #include <climits> |
| 8 | #include <exception> | ||
| 8 | #include <thread> | 9 | #include <thread> |
| 9 | #include <vector> | 10 | #include <vector> |
| 10 | 11 | ||
| @@ -152,7 +153,7 @@ public: | |||
| 152 | void EnableForStacktrace() override {} | 153 | void EnableForStacktrace() override {} |
| 153 | }; | 154 | }; |
| 154 | 155 | ||
| 155 | bool initialization_in_progress_suppress_logging = false; | 156 | bool initialization_in_progress_suppress_logging = true; |
| 156 | 157 | ||
| 157 | /** | 158 | /** |
| 158 | * Static state as a singleton. | 159 | * Static state as a singleton. |
| @@ -161,17 +162,17 @@ class Impl { | |||
| 161 | public: | 162 | public: |
| 162 | static Impl& Instance() { | 163 | static Impl& Instance() { |
| 163 | if (!instance) { | 164 | if (!instance) { |
| 164 | abort(); | 165 | throw std::runtime_error("Using Logging instance before its initialization"); |
| 165 | } | 166 | } |
| 166 | return *instance; | 167 | return *instance; |
| 167 | } | 168 | } |
| 168 | 169 | ||
| 169 | static void Initialize() { | 170 | static void Initialize() { |
| 170 | if (instance) { | 171 | if (instance) { |
| 171 | abort(); | 172 | LOG_WARNING(Log, "Reinitializing logging backend"); |
| 173 | return; | ||
| 172 | } | 174 | } |
| 173 | using namespace Common::FS; | 175 | using namespace Common::FS; |
| 174 | initialization_in_progress_suppress_logging = true; | ||
| 175 | const auto& log_dir = GetYuzuPath(YuzuPath::LogDir); | 176 | const auto& log_dir = GetYuzuPath(YuzuPath::LogDir); |
| 176 | void(CreateDir(log_dir)); | 177 | void(CreateDir(log_dir)); |
| 177 | Filter filter; | 178 | Filter filter; |