mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-12-25 06:20:06 +00:00
Add option to log synchronously, add tooltip to log filter.
This commit is contained in:
parent
05e3db3ac9
commit
cc45cc3163
@ -4,6 +4,7 @@
|
|||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <climits>
|
#include <climits>
|
||||||
|
#include <mutex>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
@ -227,8 +228,15 @@ public:
|
|||||||
if (!filter.CheckMessage(log_class, log_level)) {
|
if (!filter.CheckMessage(log_class, log_level)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
message_queue.EmplaceWait(
|
|
||||||
CreateEntry(log_class, log_level, filename, line_num, function, std::move(message)));
|
auto entry =
|
||||||
|
CreateEntry(log_class, log_level, filename, line_num, function, std::move(message));
|
||||||
|
if (Settings::values.log_async) {
|
||||||
|
message_queue.EmplaceWait(entry);
|
||||||
|
} else {
|
||||||
|
std::scoped_lock l{sync_mutex};
|
||||||
|
ForEachBackend([&entry](Backend& backend) { backend.Write(entry); });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -300,6 +308,7 @@ private:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
MPSCQueue<Entry> message_queue{};
|
MPSCQueue<Entry> message_queue{};
|
||||||
|
std::mutex sync_mutex;
|
||||||
std::chrono::steady_clock::time_point time_origin{std::chrono::steady_clock::now()};
|
std::chrono::steady_clock::time_point time_origin{std::chrono::steady_clock::now()};
|
||||||
std::jthread backend_thread;
|
std::jthread backend_thread;
|
||||||
};
|
};
|
||||||
@ -328,9 +337,11 @@ void SetColorConsoleBackendEnabled(bool enabled) {
|
|||||||
void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename,
|
void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename,
|
||||||
unsigned int line_num, const char* function, const char* format,
|
unsigned int line_num, const char* function, const char* format,
|
||||||
const fmt::format_args& args) {
|
const fmt::format_args& args) {
|
||||||
if (!initialization_in_progress_suppress_logging) {
|
if (initialization_in_progress_suppress_logging) {
|
||||||
Impl::Instance().PushEntry(log_class, log_level, filename, line_num, function,
|
return;
|
||||||
fmt::vformat(format, args));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Impl::Instance().PushEntry(log_class, log_level, filename, line_num, function,
|
||||||
|
fmt::vformat(format, args));
|
||||||
}
|
}
|
||||||
} // namespace Common::Log
|
} // namespace Common::Log
|
||||||
|
@ -170,7 +170,7 @@ const char* GetLogClassName(Class log_class) {
|
|||||||
return #x;
|
return #x;
|
||||||
#define SUB(x, y) \
|
#define SUB(x, y) \
|
||||||
case Class::x##_##y: \
|
case Class::x##_##y: \
|
||||||
return #x "." #y;
|
return #x "_" #y;
|
||||||
ALL_LOG_CLASSES()
|
ALL_LOG_CLASSES()
|
||||||
#undef CLS
|
#undef CLS
|
||||||
#undef SUB
|
#undef SUB
|
||||||
|
@ -559,6 +559,7 @@ struct Values {
|
|||||||
|
|
||||||
// Miscellaneous
|
// Miscellaneous
|
||||||
Setting<std::string> log_filter{linkage, "*:Info", "log_filter", Category::Miscellaneous};
|
Setting<std::string> log_filter{linkage, "*:Info", "log_filter", Category::Miscellaneous};
|
||||||
|
Setting<bool> log_async{linkage, true, "log_async", Category::Miscellaneous};
|
||||||
Setting<bool> use_dev_keys{linkage, false, "use_dev_keys", Category::Miscellaneous};
|
Setting<bool> use_dev_keys{linkage, false, "use_dev_keys", Category::Miscellaneous};
|
||||||
|
|
||||||
// Network
|
// Network
|
||||||
|
@ -73,6 +73,7 @@ void ConfigureDebug::SetConfiguration() {
|
|||||||
ui->disable_loop_safety_checks->setChecked(
|
ui->disable_loop_safety_checks->setChecked(
|
||||||
Settings::values.disable_shader_loop_safety_checks.GetValue());
|
Settings::values.disable_shader_loop_safety_checks.GetValue());
|
||||||
ui->extended_logging->setChecked(Settings::values.extended_logging.GetValue());
|
ui->extended_logging->setChecked(Settings::values.extended_logging.GetValue());
|
||||||
|
ui->log_async->setChecked(Settings::values.log_async.GetValue());
|
||||||
ui->perform_vulkan_check->setChecked(Settings::values.perform_vulkan_check.GetValue());
|
ui->perform_vulkan_check->setChecked(Settings::values.perform_vulkan_check.GetValue());
|
||||||
|
|
||||||
#ifdef YUZU_USE_QT_WEB_ENGINE
|
#ifdef YUZU_USE_QT_WEB_ENGINE
|
||||||
@ -115,6 +116,7 @@ void ConfigureDebug::ApplyConfiguration() {
|
|||||||
Common::Log::Filter filter;
|
Common::Log::Filter filter;
|
||||||
filter.ParseFilterString(Settings::values.log_filter.GetValue());
|
filter.ParseFilterString(Settings::values.log_filter.GetValue());
|
||||||
Common::Log::SetGlobalFilter(filter);
|
Common::Log::SetGlobalFilter(filter);
|
||||||
|
Settings::values.log_async = ui->log_async->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureDebug::changeEvent(QEvent* event) {
|
void ConfigureDebug::changeEvent(QEvent* event) {
|
||||||
|
@ -164,6 +164,20 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QCheckBox" name="log_async">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>When checked, logging will run asynchronously. This may cut the log on crashes.
|
||||||
|
When unchecked, logging will run synchronously. This will slow down the emulator, but allow all logs to be written. Useful for debugging.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Log asynchronously</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="0" column="0" colspan="2">
|
<item row="0" column="0" colspan="2">
|
||||||
<widget class="QWidget" name="logging_widget" native="true">
|
<widget class="QWidget" name="logging_widget" native="true">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -199,7 +213,14 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="log_filter_edit"/>
|
<widget class="QLineEdit" name="log_filter_edit">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Log filter in the form <class>:<level>.
|
||||||
|
Separate multiple filters with a space.
|
||||||
|
Levels: Trace, Debug, Info, Warning, Error, Critical
|
||||||
|
Classes: See Common/logging/types.h</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
Loading…
Reference in New Issue
Block a user