added message dumping for -parse option if running from console

This commit is contained in:
ALEXks
2025-06-05 19:04:56 +03:00
parent a96a4bcaa6
commit 623898d913
4 changed files with 58 additions and 51 deletions

View File

@@ -14,15 +14,13 @@
#include <map>
#include <set>
#include <utility>
#include <string>
#include <assert.h>
#include <locale>
#include <algorithm>
#include <thread>
#include <cstdint>
#include "utils.h"
#include "errors.h"
#include "utils.h"
#include "version.h"
#include "graph_loops.h"
@@ -1737,4 +1735,38 @@ void copyStringToShort(short*& result, const string& resVal, bool withEnd)
if (withEnd)
result[resVal.size()] = (short)'\0';
}
void dumpMessages(bool inCatch, const map<string, vector<Messages>>& messages, const char *vis_path)
{
json byFileArray = json::array();
for (auto& byFile : messages)
{
json inFile;
inFile["file"] = byFile.first;
json messages = json::array();
for (auto& message : byFile.second)
{
if (inCatch)
message.print(byFile.first);
messages.push_back(message.toJson());
}
inFile["messages"] = messages;
byFileArray.push_back(inFile);
}
json allMessages;
allMessages["allMessages"] = byFileArray;
const string dump = allMessages.dump().c_str();
if (dump.size())
{
FILE* outF = fopen((string(vis_path) + "/error_messages.json").c_str(), "w");
if (outF)
{
fprintf(outF, "%s", dump.c_str());
fclose(outF);
}
}
}

View File

@@ -5,7 +5,9 @@
#include <string>
#include <cstdint>
struct Messages;
struct DataDirective;
namespace Distribution
{
class Array;
@@ -98,3 +100,4 @@ std::set<DIST::Array*> fillDistributedArraysD(const DataDirective& dataDirective
std::set<std::string> fillDistributedArrays(const DataDirective& dataDirectives, const std::map<DIST::Array*, std::tuple<int, std::string, std::string>>& tableOfUniqNamesByArray, const std::map<DIST::Array*, std::set<DIST::Array*>>& arrayLinksByFuncCalls, bool onlyCommon = false, bool shortName = false);
void copyStringToShort(short*& result, const std::string& resVal, bool withEnd = true);
void dumpMessages(bool inCatch, const std::map<std::string, std::vector<Messages>>& messages, const char* vis_path);