diff options
| author | 2019-06-29 17:15:48 -0400 | |
|---|---|---|
| committer | 2019-09-22 12:34:33 -0400 | |
| commit | 82bf055ecad08bd1c3f5b041888461db5c2da79a (patch) | |
| tree | 2eb0a18b6fd7094ce999775918ef53c087afbca1 /src/core/reporter.cpp | |
| parent | Merge pull request #2683 from DarkLordZach/lock-exit (diff) | |
| download | yuzu-82bf055ecad08bd1c3f5b041888461db5c2da79a.tar.gz yuzu-82bf055ecad08bd1c3f5b041888461db5c2da79a.tar.xz yuzu-82bf055ecad08bd1c3f5b041888461db5c2da79a.zip | |
reporter: Add log output for packaged lm log data
Takes the vector from head to tail of log data and saves it.
Diffstat (limited to 'src/core/reporter.cpp')
| -rw-r--r-- | src/core/reporter.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
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 @@ | |||
| 7 | 7 | ||
| 8 | #include <fmt/chrono.h> | 8 | #include <fmt/chrono.h> |
| 9 | #include <fmt/format.h> | 9 | #include <fmt/format.h> |
| 10 | #include <fmt/ostream.h> | ||
| 11 | #include <fmt/time.h> | ||
| 10 | #include <json.hpp> | 12 | #include <json.hpp> |
| 11 | 13 | ||
| 12 | #include "common/file_util.h" | 14 | #include "common/file_util.h" |
| @@ -17,6 +19,7 @@ | |||
| 17 | #include "core/hle/kernel/hle_ipc.h" | 19 | #include "core/hle/kernel/hle_ipc.h" |
| 18 | #include "core/hle/kernel/process.h" | 20 | #include "core/hle/kernel/process.h" |
| 19 | #include "core/hle/result.h" | 21 | #include "core/hle/result.h" |
| 22 | #include "core/hle/service/lm/manager.h" | ||
| 20 | #include "core/reporter.h" | 23 | #include "core/reporter.h" |
| 21 | #include "core/settings.h" | 24 | #include "core/settings.h" |
| 22 | 25 | ||
| @@ -354,6 +357,55 @@ void Reporter::SaveErrorReport(u64 title_id, ResultCode result, | |||
| 354 | SaveToFile(std::move(out), GetPath("error_report", title_id, timestamp)); | 357 | SaveToFile(std::move(out), GetPath("error_report", title_id, timestamp)); |
| 355 | } | 358 | } |
| 356 | 359 | ||
| 360 | void Reporter::SaveLogReport(u32 destination, std::vector<Service::LM::LogMessage> messages) const { | ||
| 361 | if (!IsReportingEnabled()) { | ||
| 362 | return; | ||
| 363 | } | ||
| 364 | |||
| 365 | const auto timestamp = GetTimestamp(); | ||
| 366 | json out; | ||
| 367 | |||
| 368 | out["yuzu_version"] = GetYuzuVersionData(); | ||
| 369 | out["report_common"] = | ||
| 370 | GetReportCommonData(system.CurrentProcess()->GetTitleID(), RESULT_SUCCESS, timestamp); | ||
| 371 | |||
| 372 | out["log_destination"] = | ||
| 373 | fmt::format("{}", static_cast<Service::LM::DestinationFlag>(destination)); | ||
| 374 | |||
| 375 | auto json_messages = json::array(); | ||
| 376 | std::transform(messages.begin(), messages.end(), std::back_inserter(json_messages), | ||
| 377 | [](const Service::LM::LogMessage& message) { | ||
| 378 | json out; | ||
| 379 | out["is_head"] = fmt::format("{}", message.header.IsHeadLog()); | ||
| 380 | out["is_tail"] = fmt::format("{}", message.header.IsTailLog()); | ||
| 381 | out["pid"] = fmt::format("{:016X}", message.header.pid); | ||
| 382 | out["thread_context"] = | ||
| 383 | fmt::format("{:016X}", message.header.thread_context); | ||
| 384 | out["payload_size"] = fmt::format("{:016X}", message.header.payload_size); | ||
| 385 | out["flags"] = fmt::format("{:04X}", message.header.flags.Value()); | ||
| 386 | out["severity"] = fmt::format("{}", message.header.severity.Value()); | ||
| 387 | out["verbosity"] = fmt::format("{:02X}", message.header.verbosity); | ||
| 388 | |||
| 389 | auto fields = json::array(); | ||
| 390 | std::transform(message.fields.begin(), message.fields.end(), | ||
| 391 | std::back_inserter(fields), [](const auto& kv) { | ||
| 392 | json out; | ||
| 393 | out["type"] = fmt::format("{}", kv.first); | ||
| 394 | out["data"] = | ||
| 395 | Service::LM::FormatField(kv.first, kv.second); | ||
| 396 | return std::move(out); | ||
| 397 | }); | ||
| 398 | |||
| 399 | out["fields"] = std::move(fields); | ||
| 400 | return std::move(out); | ||
| 401 | }); | ||
| 402 | |||
| 403 | out["log_messages"] = std::move(json_messages); | ||
| 404 | |||
| 405 | SaveToFile(std::move(out), | ||
| 406 | GetPath("log_report", system.CurrentProcess()->GetTitleID(), timestamp)); | ||
| 407 | } | ||
| 408 | |||
| 357 | void Reporter::SaveFilesystemAccessReport(Service::FileSystem::LogMode log_mode, | 409 | void Reporter::SaveFilesystemAccessReport(Service::FileSystem::LogMode log_mode, |
| 358 | std::string log_message) const { | 410 | std::string log_message) const { |
| 359 | if (!IsReportingEnabled()) | 411 | if (!IsReportingEnabled()) |