diff options
| author | 2019-10-08 20:23:13 -0400 | |
|---|---|---|
| committer | 2019-10-08 20:23:13 -0400 | |
| commit | b9c831de623df5a58cc5aa47392d6841bfef8d8b (patch) | |
| tree | 2242bd5c0931997af15beccde978434b79a8d1d9 /src/core/reporter.cpp | |
| parent | Merge pull request #2961 from DarkLordZach/azure-tag-names (diff) | |
| parent | lm: Flush manager output on core shutdown (diff) | |
| download | yuzu-b9c831de623df5a58cc5aa47392d6841bfef8d8b.tar.gz yuzu-b9c831de623df5a58cc5aa47392d6841bfef8d8b.tar.xz yuzu-b9c831de623df5a58cc5aa47392d6841bfef8d8b.zip | |
Merge pull request #2654 from DarkLordZach/lm-log-rewrite
lm: Rewrite logger to use core reporting services
Diffstat (limited to 'src/core/reporter.cpp')
| -rw-r--r-- | src/core/reporter.cpp | 51 |
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 @@ | |||
| 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> | ||
| 10 | #include <json.hpp> | 11 | #include <json.hpp> |
| 11 | 12 | ||
| 12 | #include "common/file_util.h" | 13 | #include "common/file_util.h" |
| @@ -17,6 +18,7 @@ | |||
| 17 | #include "core/hle/kernel/hle_ipc.h" | 18 | #include "core/hle/kernel/hle_ipc.h" |
| 18 | #include "core/hle/kernel/process.h" | 19 | #include "core/hle/kernel/process.h" |
| 19 | #include "core/hle/result.h" | 20 | #include "core/hle/result.h" |
| 21 | #include "core/hle/service/lm/manager.h" | ||
| 20 | #include "core/reporter.h" | 22 | #include "core/reporter.h" |
| 21 | #include "core/settings.h" | 23 | #include "core/settings.h" |
| 22 | 24 | ||
| @@ -354,6 +356,55 @@ void Reporter::SaveErrorReport(u64 title_id, ResultCode result, | |||
| 354 | SaveToFile(std::move(out), GetPath("error_report", title_id, timestamp)); | 356 | SaveToFile(std::move(out), GetPath("error_report", title_id, timestamp)); |
| 355 | } | 357 | } |
| 356 | 358 | ||
| 359 | void Reporter::SaveLogReport(u32 destination, std::vector<Service::LM::LogMessage> messages) const { | ||
| 360 | if (!IsReportingEnabled()) { | ||
| 361 | return; | ||
| 362 | } | ||
| 363 | |||
| 364 | const auto timestamp = GetTimestamp(); | ||
| 365 | json out; | ||
| 366 | |||
| 367 | out["yuzu_version"] = GetYuzuVersionData(); | ||
| 368 | out["report_common"] = | ||
| 369 | GetReportCommonData(system.CurrentProcess()->GetTitleID(), RESULT_SUCCESS, timestamp); | ||
| 370 | |||
| 371 | out["log_destination"] = | ||
| 372 | fmt::format("{}", static_cast<Service::LM::DestinationFlag>(destination)); | ||
| 373 | |||
| 374 | auto json_messages = json::array(); | ||
| 375 | std::transform(messages.begin(), messages.end(), std::back_inserter(json_messages), | ||
| 376 | [](const Service::LM::LogMessage& message) { | ||
| 377 | json out; | ||
| 378 | out["is_head"] = fmt::format("{}", message.header.IsHeadLog()); | ||
| 379 | out["is_tail"] = fmt::format("{}", message.header.IsTailLog()); | ||
| 380 | out["pid"] = fmt::format("{:016X}", message.header.pid); | ||
| 381 | out["thread_context"] = | ||
| 382 | fmt::format("{:016X}", message.header.thread_context); | ||
| 383 | out["payload_size"] = fmt::format("{:016X}", message.header.payload_size); | ||
| 384 | out["flags"] = fmt::format("{:04X}", message.header.flags.Value()); | ||
| 385 | out["severity"] = fmt::format("{}", message.header.severity.Value()); | ||
| 386 | out["verbosity"] = fmt::format("{:02X}", message.header.verbosity); | ||
| 387 | |||
| 388 | auto fields = json::array(); | ||
| 389 | std::transform(message.fields.begin(), message.fields.end(), | ||
| 390 | std::back_inserter(fields), [](const auto& kv) { | ||
| 391 | json out; | ||
| 392 | out["type"] = fmt::format("{}", kv.first); | ||
| 393 | out["data"] = | ||
| 394 | Service::LM::FormatField(kv.first, kv.second); | ||
| 395 | return out; | ||
| 396 | }); | ||
| 397 | |||
| 398 | out["fields"] = std::move(fields); | ||
| 399 | return out; | ||
| 400 | }); | ||
| 401 | |||
| 402 | out["log_messages"] = std::move(json_messages); | ||
| 403 | |||
| 404 | SaveToFile(std::move(out), | ||
| 405 | GetPath("log_report", system.CurrentProcess()->GetTitleID(), timestamp)); | ||
| 406 | } | ||
| 407 | |||
| 357 | void Reporter::SaveFilesystemAccessReport(Service::FileSystem::LogMode log_mode, | 408 | void Reporter::SaveFilesystemAccessReport(Service::FileSystem::LogMode log_mode, |
| 358 | std::string log_message) const { | 409 | std::string log_message) const { |
| 359 | if (!IsReportingEnabled()) | 410 | if (!IsReportingEnabled()) |