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

DPLT-1055 Log multiple console.log / context.log arguments #133

Merged
merged 1 commit into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions indexer-js-queue-handler/indexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ export default class Indexer {
set: (key, value) => {
mutationsReturnValue.keysValues[key] = value;
},
log: async (log) => { // starting with imperative logging for both imperative and functional contexts
return await this.writeLog(functionName, block_height, log);
log: async (...log) => { // starting with imperative logging for both imperative and functional contexts
return await this.writeLog(functionName, block_height, ...log);
}

};
Expand Down Expand Up @@ -253,8 +253,8 @@ export default class Indexer {
throw e; // allow catch outside of vm.run to receive the error
}
},
log: async (log) => {
return await this.writeLog(functionName, block_height, log);
log: async (...log) => {
return await this.writeLog(functionName, block_height, ...log);
},
putMetric: (name, value) => {
const [accountId, fnName] = functionName.split('/');
Expand Down
8 changes: 4 additions & 4 deletions indexer-js-queue-handler/indexer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,14 +480,14 @@ mutation _1 { set(functionName: "buildnear.testnet/test", key: "foo2", data: "in

test('Indexer.runFunctions() console.logs', async () => {
const logs = []
const context = {log: (m) => {
logs.push(m)
const context = {log: (...m) => {
logs.push(...m)
}};
const vm = new VM();
vm.freeze(context, 'context');
vm.freeze(context, 'console');
await vm.run('console.log("hello"); context.log("world")');
expect(logs).toEqual(['hello','world']);
await vm.run('console.log("hello", "brave new"); context.log("world")');
expect(logs).toEqual(['hello','brave new','world']);
});

test("Errors thrown in VM can be caught outside the VM", async () => {
Expand Down