From 6212df3beb38d0484b6ceedad18be99f107f7d96 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Sun, 22 Sep 2019 12:28:21 -0400 Subject: [PATCH] lm: Flush manager output on core shutdown --- src/core/core.cpp | 2 ++ src/core/hle/service/lm/manager.cpp | 12 ++++++++---- src/core/hle/service/lm/manager.h | 4 +++- src/core/reporter.cpp | 5 ++--- src/core/reporter.h | 3 --- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/core/core.cpp b/src/core/core.cpp index eb2c2e204..bf62085a8 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -250,6 +250,8 @@ struct System::Impl { telemetry_session->AddField(Telemetry::FieldType::Performance, "Mean_Frametime_MS", perf_stats->GetMeanFrametime()); + lm_manager.Flush(); + is_powered_on = false; exit_lock = false; diff --git a/src/core/hle/service/lm/manager.cpp b/src/core/hle/service/lm/manager.cpp index fd8edaf46..b67081b86 100644 --- a/src/core/hle/service/lm/manager.cpp +++ b/src/core/hle/service/lm/manager.cpp @@ -13,7 +13,7 @@ namespace Service::LM { std::ostream& operator<<(std::ostream& os, DestinationFlag dest) { std::vector array; const auto check_single_flag = [dest, &array](DestinationFlag check, std::string name) { - if ((static_cast(check) & static_cast(dest)) > 0) { + if ((static_cast(check) & static_cast(dest)) != 0) { array.emplace_back(std::move(name)); } }; @@ -75,7 +75,7 @@ std::string FormatField(Field type, const std::vector& data) { if (data.size() >= sizeof(u32)) { u32 line; std::memcpy(&line, data.data(), sizeof(u32)); - return fmt::format("{:08X}", line); + return fmt::format("{}", line); } return "[ERROR DECODING LINE NUMBER]"; case Field::Message: @@ -114,16 +114,20 @@ void Manager::Log(LogMessage message) { } } +void Manager::Flush() { + FinalizeLog(); +} + void Manager::InitializeLog() { current_log.clear(); - LOG_INFO(Service_LM, "Initialized new log session!"); + LOG_INFO(Service_LM, "Initialized new log session"); } void Manager::FinalizeLog() { reporter.SaveLogReport(static_cast(destination), std::move(current_log)); - LOG_INFO(Service_LM, "Finalized current log session!"); + LOG_INFO(Service_LM, "Finalized current log session"); } } // namespace Service::LM diff --git a/src/core/hle/service/lm/manager.h b/src/core/hle/service/lm/manager.h index af0a27257..544e636ba 100644 --- a/src/core/hle/service/lm/manager.h +++ b/src/core/hle/service/lm/manager.h @@ -81,7 +81,7 @@ std::string FormatField(Field type, const std::vector& data); class Manager { public: - Manager(Core::Reporter& reporter); + explicit Manager(Core::Reporter& reporter); ~Manager(); void SetEnabled(bool enabled); @@ -89,6 +89,8 @@ public: void Log(LogMessage message); + void Flush(); + private: void InitializeLog(); void FinalizeLog(); 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> data, - std::optional user_id = {}) const; void SavePlayReport(PlayReportType type, u64 title_id, std::vector> data, std::optional process_id = {}, std::optional user_id = {}) const;