From 82bf055ecad08bd1c3f5b041888461db5c2da79a Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Sat, 29 Jun 2019 17:15:48 -0400 Subject: reporter: Add log output for packaged lm log data Takes the vector from head to tail of log data and saves it. --- src/core/reporter.cpp | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'src/core/reporter.cpp') diff --git a/src/core/reporter.cpp b/src/core/reporter.cpp index 9c657929e..a465d7421 100644 --- a/src/core/reporter.cpp +++ b/src/core/reporter.cpp @@ -7,6 +7,8 @@ #include #include +#include +#include #include #include "common/file_util.h" @@ -17,6 +19,7 @@ #include "core/hle/kernel/hle_ipc.h" #include "core/hle/kernel/process.h" #include "core/hle/result.h" +#include "core/hle/service/lm/manager.h" #include "core/reporter.h" #include "core/settings.h" @@ -354,6 +357,55 @@ void Reporter::SaveErrorReport(u64 title_id, ResultCode result, SaveToFile(std::move(out), GetPath("error_report", title_id, timestamp)); } +void Reporter::SaveLogReport(u32 destination, std::vector messages) const { + if (!IsReportingEnabled()) { + return; + } + + const auto timestamp = GetTimestamp(); + json out; + + out["yuzu_version"] = GetYuzuVersionData(); + out["report_common"] = + GetReportCommonData(system.CurrentProcess()->GetTitleID(), RESULT_SUCCESS, timestamp); + + out["log_destination"] = + fmt::format("{}", static_cast(destination)); + + auto json_messages = json::array(); + std::transform(messages.begin(), messages.end(), std::back_inserter(json_messages), + [](const Service::LM::LogMessage& message) { + json out; + out["is_head"] = fmt::format("{}", message.header.IsHeadLog()); + out["is_tail"] = fmt::format("{}", message.header.IsTailLog()); + out["pid"] = fmt::format("{:016X}", message.header.pid); + out["thread_context"] = + fmt::format("{:016X}", message.header.thread_context); + out["payload_size"] = fmt::format("{:016X}", message.header.payload_size); + out["flags"] = fmt::format("{:04X}", message.header.flags.Value()); + out["severity"] = fmt::format("{}", message.header.severity.Value()); + out["verbosity"] = fmt::format("{:02X}", message.header.verbosity); + + auto fields = json::array(); + std::transform(message.fields.begin(), message.fields.end(), + std::back_inserter(fields), [](const auto& kv) { + json out; + out["type"] = fmt::format("{}", kv.first); + out["data"] = + Service::LM::FormatField(kv.first, kv.second); + return std::move(out); + }); + + out["fields"] = std::move(fields); + return std::move(out); + }); + + out["log_messages"] = std::move(json_messages); + + SaveToFile(std::move(out), + GetPath("log_report", system.CurrentProcess()->GetTitleID(), timestamp)); +} + void Reporter::SaveFilesystemAccessReport(Service::FileSystem::LogMode log_mode, std::string log_message) const { if (!IsReportingEnabled()) -- cgit v1.2.3 From 6212df3beb38d0484b6ceedad18be99f107f7d96 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Sun, 22 Sep 2019 12:28:21 -0400 Subject: lm: Flush manager output on core shutdown --- src/core/reporter.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/core/reporter.cpp') diff --git a/src/core/reporter.cpp b/src/core/reporter.cpp index a465d7421..6f4af77fd 100644 --- a/src/core/reporter.cpp +++ b/src/core/reporter.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include "common/file_util.h" @@ -393,11 +392,11 @@ void Reporter::SaveLogReport(u32 destination, std::vector