Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix log index #203

Merged
merged 1 commit into from
Jul 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions src/sm/sm_main/debug/full-tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,19 +377,21 @@ class FullTracer {

// Append logs correctly formatted to response logs
this.logs = this.logs.filter((n) => n); // Remove null values
// eslint-disable-next-line no-restricted-syntax
let logIndex = 0;
// Put all logs in an array
let auxLogs = [];
for (let i = 0; i < this.logs.length; i++) {
const logsToAdd = Object.values(this.logs[i]);
for (let j = 0; j < logsToAdd.length; j++) {
const singleLog = logsToAdd[j];
// set logIndex
singleLog.index = logIndex;
// store log
this.finalTrace.responses[this.txCount].logs.push(singleLog);
// increase logIndex
logIndex += 1;
}
auxLogs = auxLogs.concat(Object.values(this.logs[i]));
}
// Sort auxLogs by index
auxLogs.sort((a, b) => a.index - b.index);
// Update index to be sequential
// eslint-disable-next-line no-restricted-syntax
for (let i = 0; i < auxLogs.length; i++) {
const singleLog = auxLogs[i];
// set logIndex
singleLog.index = i;
// store log
this.finalTrace.responses[this.txCount].logs.push(singleLog);
}

// create directory if it does not exist
Expand Down