summaryrefslogtreecommitdiff
path: root/src/yuzu/main.cpp
diff options
context:
space:
mode:
authoryzct12345 <87620833+yzct12345@users.noreply.github.com>2021-08-13 18:39:45 +0000
committerGitHub <noreply@github.com>2021-08-13 18:39:45 +0000
commit001675dced1b7b751d1db4f0d6490776c613df2f (patch)
tree151923c90c42bdcede2581ddf6b56768bfcafc01 /src/yuzu/main.cpp
parent71d8d84b59ae6e1cfad37d70e6ea7d61001326f3 (diff)
logging: Simplify and make thread-safe
This simplifies the logging system. This also fixes some lost messages on startup. The simplification is simple. I removed unused functions and moved most things in the .h to the .cpp. I replaced the unnecessary linked list with its contents laid out as three member variables. Anything that went through the linked list now directly accesses the backends. Generic functions are replaced with those for each specific use case and there aren't many. This change increases coupling but we gain back more KISS and encapsulation. With those changes it was easy to make it thread-safe. I just removed the mutex and turned a boolean atomic. I was planning to use this thread-safety in my next PR about stacktraces. It was actually async-signal-safety at first but I ended up using a different approach. Anyway getting rid of the linked list is important for that because have the list of backends constantly changing complicates things.
Diffstat (limited to 'src/yuzu/main.cpp')
-rw-r--r--src/yuzu/main.cpp19
1 files changed, 2 insertions, 17 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 5940e0cfd..1bae1489f 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -175,21 +175,6 @@ void GMainWindow::ShowTelemetryCallout() {
const int GMainWindow::max_recent_files_item;
-static void InitializeLogging() {
- using namespace Common;
-
- Log::Filter log_filter;
- log_filter.ParseFilterString(Settings::values.log_filter.GetValue());
- Log::SetGlobalFilter(log_filter);
-
- const auto log_dir = FS::GetYuzuPath(FS::YuzuPath::LogDir);
- void(FS::CreateDir(log_dir));
- Log::AddBackend(std::make_unique<Log::FileBackend>(log_dir / LOG_FILE));
-#ifdef _WIN32
- Log::AddBackend(std::make_unique<Log::DebuggerBackend>());
-#endif
-}
-
static void RemoveCachedContents() {
const auto cache_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir);
const auto offline_fonts = cache_dir / "fonts";
@@ -207,8 +192,6 @@ GMainWindow::GMainWindow()
: input_subsystem{std::make_shared<InputCommon::InputSubsystem>()},
config{std::make_unique<Config>()}, vfs{std::make_shared<FileSys::RealVfsFilesystem>()},
provider{std::make_unique<FileSys::ManualContentProvider>()} {
- InitializeLogging();
-
LoadTranslation();
setAcceptDrops(true);
@@ -3398,6 +3381,7 @@ void GMainWindow::SetDiscordEnabled([[maybe_unused]] bool state) {
#endif
int main(int argc, char* argv[]) {
+ Common::Log::Initialize();
Common::DetachedTasks detached_tasks;
MicroProfileOnThreadCreate("Frontend");
SCOPE_EXIT({ MicroProfileShutdown(); });
@@ -3437,6 +3421,7 @@ int main(int argc, char* argv[]) {
// generating shaders
setlocale(LC_ALL, "C");
+ Core::System::InitializeGlobalInstance();
GMainWindow main_window;
// After settings have been loaded by GMainWindow, apply the filter
main_window.show();