55 */
66
77#include " ProjMgrRpcServer.h"
8+ #include " ProjMgrLogger.h"
89#include " ProjMgr.h"
910#include " ProductInfo.h"
1011#include < RteFsUtils.h>
@@ -176,6 +177,18 @@ namespace Args {
176177 void to_json (nlohmann::json& j, const Results& r) {
177178 to_json (j, " validation" , r.validation );
178179 }
180+
181+ // GetLogMessages
182+ struct LogMessages {
183+ optional<vector<string>> info;
184+ optional<vector<string>> errors;
185+ optional<vector<string>> warnings;
186+ };
187+ void to_json (nlohmann::json& j, const LogMessages& m) {
188+ to_json (j, " info" , m.info );
189+ to_json (j, " errors" , m.errors );
190+ to_json (j, " warnings" , m.warnings );
191+ }
179192}
180193
181194class RpcHandler {
@@ -192,6 +205,7 @@ class RpcHandler {
192205 const Args::PacksInfo GetPacksInfo (const string& context);
193206 const Args::ComponentsInfo GetComponentsInfo (const string& context);
194207 const Args::Results ValidateComponents (const string& context, const StrVec& components);
208+ const Args::LogMessages GetLogMessages (void );
195209
196210protected:
197211 enum Exception
@@ -231,6 +245,7 @@ bool ProjMgrRpcServer::Run(void) {
231245 jsonServer.Add (" GetPacksInfo" , GetHandle (&RpcHandler::GetPacksInfo , handler), { " context" });
232246 jsonServer.Add (" GetComponentsInfo" , GetHandle (&RpcHandler::GetComponentsInfo , handler), { " context" });
233247 jsonServer.Add (" ValidateComponents" , GetHandle (&RpcHandler::ValidateComponents , handler), { " context" , " components" });
248+ jsonServer.Add (" GetLogMessages" , GetHandle (&RpcHandler::GetLogMessages , handler));
234249
235250 while (!m_shutdown && !cin.fail ()) {
236251 // Get request
@@ -476,3 +491,35 @@ const Args::Results RpcHandler::ValidateComponents(const string& context, const
476491 }
477492 return results;
478493}
494+
495+ const Args::LogMessages RpcHandler::GetLogMessages (void ) {
496+ StrVec infoVec;
497+ for (const auto & [_, info] : ProjMgrLogger::Get ().GetInfos ()) {
498+ for (const auto & msg : info) {
499+ CollectionUtils::PushBackUniquely (infoVec, msg);
500+ }
501+ }
502+ StrVec errorsVec;
503+ for (const auto & [_, errors] : ProjMgrLogger::Get ().GetErrors ()) {
504+ for (const auto & msg : errors) {
505+ CollectionUtils::PushBackUniquely (errorsVec, msg);
506+ }
507+ }
508+ StrVec warningsVec;
509+ for (const auto & [_, warnings] : ProjMgrLogger::Get ().GetWarns ()) {
510+ for (const auto & msg : warnings) {
511+ CollectionUtils::PushBackUniquely (warningsVec, msg);
512+ }
513+ }
514+ Args::LogMessages messages;
515+ if (!infoVec.empty ()) {
516+ messages.info = infoVec;
517+ }
518+ if (!errorsVec.empty ()) {
519+ messages.errors = errorsVec;
520+ }
521+ if (!warningsVec.empty ()) {
522+ messages.warnings = warningsVec;
523+ }
524+ return messages;
525+ }
0 commit comments