summaryrefslogtreecommitdiffstats
path: root/src/core/reporter.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2019-10-09 02:23:13 +0200
committerGitHub <noreply@github.com>2019-10-09 02:23:13 +0200
commitb9c831de623df5a58cc5aa47392d6841bfef8d8b (patch)
tree2242bd5c0931997af15beccde978434b79a8d1d9 /src/core/reporter.cpp
parentMerge pull request #2961 from DarkLordZach/azure-tag-names (diff)
parentlm: Flush manager output on core shutdown (diff)
downloadyuzu-b9c831de623df5a58cc5aa47392d6841bfef8d8b.tar
yuzu-b9c831de623df5a58cc5aa47392d6841bfef8d8b.tar.gz
yuzu-b9c831de623df5a58cc5aa47392d6841bfef8d8b.tar.bz2
yuzu-b9c831de623df5a58cc5aa47392d6841bfef8d8b.tar.lz
yuzu-b9c831de623df5a58cc5aa47392d6841bfef8d8b.tar.xz
yuzu-b9c831de623df5a58cc5aa47392d6841bfef8d8b.tar.zst
yuzu-b9c831de623df5a58cc5aa47392d6841bfef8d8b.zip
Diffstat (limited to 'src/core/reporter.cpp')
-rw-r--r--src/core/reporter.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/core/reporter.cpp b/src/core/reporter.cpp
index 9c657929e..6f4af77fd 100644
--- a/src/core/reporter.cpp
+++ b/src/core/reporter.cpp
@@ -7,6 +7,7 @@
#include <fmt/chrono.h>
#include <fmt/format.h>
+#include <fmt/ostream.h>
#include <json.hpp>
#include "common/file_util.h"
@@ -17,6 +18,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 +356,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<Service::LM::LogMessage> 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<Service::LM::DestinationFlag>(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 out;
+ });
+
+ out["fields"] = std::move(fields);
+ return 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())