diff --git a/src/citra/citra.cpp b/src/citra/citra.cpp index 6d422e4da4..a71aa7dbec 100644 --- a/src/citra/citra.cpp +++ b/src/citra/citra.cpp @@ -374,7 +374,7 @@ int main(int argc, char** argv) { break; // Expected case } - Core::Telemetry().AddField(Telemetry::FieldType::App, "Frontend", "SDL"); + system.TelemetrySession().AddField(Telemetry::FieldType::App, "Frontend", "SDL"); if (use_multiplayer) { if (auto member = Network::GetRoomMember().lock()) { diff --git a/src/citra_qt/compatdb.cpp b/src/citra_qt/compatdb.cpp index 4209b16cf8..6b6c7f37f6 100644 --- a/src/citra_qt/compatdb.cpp +++ b/src/citra_qt/compatdb.cpp @@ -51,8 +51,8 @@ void CompatDB::Submit() { case CompatDBPage::Final: back(); LOG_DEBUG(Frontend, "Compatibility Rating: {}", compatibility->checkedId()); - Core::Telemetry().AddField(Telemetry::FieldType::UserFeedback, "Compatibility", - compatibility->checkedId()); + Core::System::GetInstance().TelemetrySession().AddField( + Telemetry::FieldType::UserFeedback, "Compatibility", compatibility->checkedId()); button(NextButton)->setEnabled(false); button(NextButton)->setText(tr("Submitting")); diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index f3d1d6582c..bcff0b9fce 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -799,7 +799,7 @@ bool GMainWindow::LoadROM(const QString& filename) { game_path = filename; - Core::Telemetry().AddField(Telemetry::FieldType::App, "Frontend", "Qt"); + system.TelemetrySession().AddField(Telemetry::FieldType::App, "Frontend", "Qt"); return true; } diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index d440d910ab..e28b527efb 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -39,8 +39,10 @@ public: Impl(Impl const&) = delete; const Impl& operator=(Impl const&) = delete; - void PushEntry(Entry e) { - message_queue.Push(std::move(e)); + void PushEntry(Class log_class, Level log_level, const char* filename, unsigned int line_num, + const char* function, std::string message) { + message_queue.Push( + CreateEntry(log_class, log_level, filename, line_num, function, std::move(message))); } void AddBackend(std::unique_ptr backend) { @@ -108,11 +110,33 @@ private: backend_thread.join(); } + Entry CreateEntry(Class log_class, Level log_level, const char* filename, unsigned int line_nr, + const char* function, std::string message) const { + using std::chrono::duration_cast; + using std::chrono::steady_clock; + + // matches from the beginning up to the last '../' or 'src/' + static const std::regex trim_source_path(R"(.*([\/\\]|^)((\.\.)|(src))[\/\\])"); + + Entry entry; + entry.timestamp = + duration_cast(steady_clock::now() - time_origin); + entry.log_class = log_class; + entry.log_level = log_level; + entry.filename = std::regex_replace(filename, trim_source_path, ""); + entry.line_num = line_nr; + entry.function = function; + entry.message = std::move(message); + + return entry; + } + std::mutex writing_mutex; std::thread backend_thread; std::vector> backends; Common::MPSCQueue message_queue; Filter filter; + std::chrono::steady_clock::time_point time_origin{std::chrono::steady_clock::now()}; }; void ConsoleBackend::Write(const Entry& entry) { @@ -249,27 +273,6 @@ const char* GetLevelName(Level log_level) { #undef LVL } -Entry CreateEntry(Class log_class, Level log_level, const char* filename, unsigned int line_nr, - const char* function, std::string message) { - using std::chrono::duration_cast; - using std::chrono::steady_clock; - - // matches from the beginning up to the last '../' or 'src/' - static const std::regex trim_source_path(R"(.*([\/\\]|^)((\.\.)|(src))[\/\\])"); - static steady_clock::time_point time_origin = steady_clock::now(); - - Entry entry; - entry.timestamp = duration_cast(steady_clock::now() - time_origin); - entry.log_class = log_class; - entry.log_level = log_level; - entry.filename = std::regex_replace(filename, trim_source_path, ""); - entry.line_num = line_nr; - entry.function = function; - entry.message = std::move(message); - - return entry; -} - void SetGlobalFilter(const Filter& filter) { Impl::Instance().SetGlobalFilter(filter); } @@ -294,9 +297,7 @@ void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename, if (!filter.CheckMessage(log_class, log_level)) return; - Entry entry = - CreateEntry(log_class, log_level, filename, line_num, function, fmt::vformat(format, args)); - - instance.PushEntry(std::move(entry)); + instance.PushEntry(log_class, log_level, filename, line_num, function, + fmt::vformat(format, args)); } } // namespace Log diff --git a/src/common/logging/backend.h b/src/common/logging/backend.h index 781c63628d..57884e247a 100644 --- a/src/common/logging/backend.h +++ b/src/common/logging/backend.h @@ -136,10 +136,6 @@ const char* GetLogClassName(Class log_class); */ const char* GetLevelName(Level log_level); -/// Creates a log entry by formatting the given source location, and message. -Entry CreateEntry(Class log_class, Level log_level, const char* filename, unsigned int line_nr, - const char* function, std::string message); - /** * The global filter will prevent any messages from even being processed if they are filtered. Each * backend can have a filter, but if the level is lower than the global filter, the backend will diff --git a/src/core/core.cpp b/src/core/core.cpp index 2696118e2f..a2d8df02be 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -286,13 +286,13 @@ void System::RegisterSoftwareKeyboard(std::shared_ptrAddField(Telemetry::FieldType::Performance, "Shutdown_EmulationSpeed", + perf_results.emulation_speed * 100.0); + telemetry_session->AddField(Telemetry::FieldType::Performance, "Shutdown_Framerate", + perf_results.game_fps); + telemetry_session->AddField(Telemetry::FieldType::Performance, "Shutdown_Frametime", + perf_results.frametime * 1000.0); // Shutdown emulation session GDBStub::Shutdown(); diff --git a/src/core/core.h b/src/core/core.h index 44e6ea796b..063d6d1b55 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -303,8 +303,4 @@ inline AudioCore::DspInterface& DSP() { return System::GetInstance().DSP(); } -inline TelemetrySession& Telemetry() { - return System::GetInstance().TelemetrySession(); -} - } // namespace Core diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp index 87aca79acd..21237d862d 100644 --- a/src/core/loader/ncch.cpp +++ b/src/core/loader/ncch.cpp @@ -172,7 +172,8 @@ ResultStatus AppLoader_NCCH::Load(std::shared_ptr& process) { overlay_ncch = &update_ncch; } - Core::Telemetry().AddField(Telemetry::FieldType::Session, "ProgramId", program_id); + auto& system = Core::System::GetInstance(); + system.TelemetrySession().AddField(Telemetry::FieldType::Session, "ProgramId", program_id); if (auto room_member = Network::GetRoomMember().lock()) { Network::GameInfo game_info; @@ -187,7 +188,7 @@ ResultStatus AppLoader_NCCH::Load(std::shared_ptr& process) { if (ResultStatus::Success != result) return result; - Core::System::GetInstance().ArchiveManager().RegisterSelfNCCH(*this); + system.ArchiveManager().RegisterSelfNCCH(*this); ParseRegionLockoutInfo(); diff --git a/src/video_core/renderer_opengl/gl_shader_gen.cpp b/src/video_core/renderer_opengl/gl_shader_gen.cpp index 3ea883038f..fdf139c3cb 100644 --- a/src/video_core/renderer_opengl/gl_shader_gen.cpp +++ b/src/video_core/renderer_opengl/gl_shader_gen.cpp @@ -1549,8 +1549,8 @@ vec4 secondary_fragment_color = vec4(0.0); // Blend the fog out += "last_tex_env_out.rgb = mix(fog_color.rgb, last_tex_env_out.rgb, fog_factor);\n"; } else if (state.fog_mode == TexturingRegs::FogMode::Gas) { - Core::Telemetry().AddField(Telemetry::FieldType::Session, "VideoCore_Pica_UseGasMode", - true); + Core::System::GetInstance().TelemetrySession().AddField(Telemetry::FieldType::Session, + "VideoCore_Pica_UseGasMode", true); LOG_CRITICAL(Render_OpenGL, "Unimplemented gas mode"); out += "discard; }"; return out; diff --git a/src/video_core/renderer_opengl/pica_to_gl.h b/src/video_core/renderer_opengl/pica_to_gl.h index 0bdc63d4a4..e923bb838f 100644 --- a/src/video_core/renderer_opengl/pica_to_gl.h +++ b/src/video_core/renderer_opengl/pica_to_gl.h @@ -83,9 +83,9 @@ inline GLenum WrapMode(Pica::TexturingRegs::TextureConfig::WrapMode mode) { } if (index > 3) { - Core::Telemetry().AddField(Telemetry::FieldType::Session, - "VideoCore_Pica_UnsupportedTextureWrapMode", - static_cast(index)); + Core::System::GetInstance().TelemetrySession().AddField( + Telemetry::FieldType::Session, "VideoCore_Pica_UnsupportedTextureWrapMode", + static_cast(index)); LOG_WARNING(Render_OpenGL, "Using texture wrap mode {}", index); } diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index fc63bfea7c..8084ce8e78 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp @@ -552,9 +552,10 @@ Core::System::ResultStatus RendererOpenGL::Init() { LOG_INFO(Render_OpenGL, "GL_VENDOR: {}", gpu_vendor); LOG_INFO(Render_OpenGL, "GL_RENDERER: {}", gpu_model); - Core::Telemetry().AddField(Telemetry::FieldType::UserSystem, "GPU_Vendor", gpu_vendor); - Core::Telemetry().AddField(Telemetry::FieldType::UserSystem, "GPU_Model", gpu_model); - Core::Telemetry().AddField(Telemetry::FieldType::UserSystem, "GPU_OpenGL_Version", gl_version); + auto& telemetry_session = Core::System::GetInstance().TelemetrySession(); + telemetry_session.AddField(Telemetry::FieldType::UserSystem, "GPU_Vendor", gpu_vendor); + telemetry_session.AddField(Telemetry::FieldType::UserSystem, "GPU_Model", gpu_model); + telemetry_session.AddField(Telemetry::FieldType::UserSystem, "GPU_OpenGL_Version", gl_version); if (!strcmp(gpu_vendor, "GDI Generic")) { return Core::System::ResultStatus::ErrorVideoCore_ErrorGenericDrivers;