Skip to content

Commit

Permalink
Emu: try to make "Silence All Logs" dynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
Megamouse committed Mar 29, 2020
1 parent 0da0979 commit 45168aa
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
29 changes: 24 additions & 5 deletions rpcs3/Emu/System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "../Crypto/unself.h"
#include "../Crypto/unpkg.h"
#include "util/yaml.hpp"
#include "util/logs.hpp"

#include "cereal/archives/binary.hpp"

Expand Down Expand Up @@ -1528,11 +1529,7 @@ void Emulator::Run(bool start_playtime)
m_pause_amend_time = 0;
m_state = system_state::running;

if (g_cfg.misc.silence_all_logs)
{
sys_log.notice("Now disabling logging...");
logs::silence();
}
ConfigureLogs();

auto on_select = [](u32, cpu_thread& cpu)
{
Expand Down Expand Up @@ -1822,6 +1819,28 @@ s32 error_code::error_report(const fmt_type_info* sup, u64 arg, const fmt_type_i
return static_cast<s32>(arg);
}

void Emulator::ConfigureLogs()
{
const bool logs_were_silenced = m_logs_silenced;
m_logs_silenced = g_cfg.misc.silence_all_logs.get();

if (logs_were_silenced == m_logs_silenced)
{
return;
}

if (m_logs_silenced)
{
sys_log.notice("Disabling logging...");
logs::silence();
}
else
{
// Nothing to do here because loading a config file will set log levels with cfg::log_entry::set_map
sys_log.notice("Logging enabled");
}
}

template <>
void stx::manual_fixed_typemap<void>::init_reporter(const char* name, unsigned long long created) const noexcept
{
Expand Down
10 changes: 6 additions & 4 deletions rpcs3/Emu/System.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class Emulator final
bool m_force_global_config = false;
bool m_force_boot = false;
bool m_has_gui = true;
bool m_logs_silenced = false;

public:
Emulator() = default;
Expand Down Expand Up @@ -175,10 +176,6 @@ class Emulator final
bool BootRsxCapture(const std::string& path);
bool InstallPkg(const std::string& path);

private:
void LimitCacheSize();

public:
#ifdef _WIN32
static std::string GetExeDir();
#endif
Expand Down Expand Up @@ -214,6 +211,11 @@ class Emulator final
std::string GetFormattedTitle(double fps) const;

u32 GetMaxThreads() const;

void ConfigureLogs();

private:
void LimitCacheSize();
};

extern Emulator Emu;
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/system_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ struct cfg_root : cfg::node
cfg::_bool show_shader_compilation_hint{ this, "Show shader compilation hint", true, true };
cfg::_bool use_native_interface{ this, "Use native user interface", true };
cfg::string gdb_server{ this, "GDB Server", "127.0.0.1:2345" };
cfg::_bool silence_all_logs{ this, "Silence All Logs", false, false };
cfg::_bool silence_all_logs{ this, "Silence All Logs", false, true };
cfg::string title_format{ this, "Window Title Format", "FPS: %F | %R | %V | %T [%t]", true };

} misc{ this };
Expand Down
1 change: 1 addition & 0 deletions rpcs3/rpcs3qt/gui_application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ void gui_application::OnChangeStyleSheetRequest(const QString& path)

void gui_application::OnEmuSettingsChange()
{
Emu.ConfigureLogs();
rsx::overlays::reset_performance_overlay();
}

Expand Down

0 comments on commit 45168aa

Please sign in to comment.