Merge pull request #799 from embark-framework/feature/trace-console-log

Use trace logger for code runner error
This commit is contained in:
Jonathan Rainville 2018-09-12 09:55:47 -04:00 committed by GitHub
commit 0f635f8a33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -8,7 +8,7 @@ class CodeRunner {
this.events = options.events;
this.ipc = options.ipc;
this.commands = [];
this.runCode = new RunCode();
this.runCode = new RunCode({logger: this.logger});
this.registerIpcEvents();
this.IpcClientListen();
this.registerEvents();

View File

@ -1,7 +1,8 @@
const vm = require('vm');
class RunCode {
constructor() {
constructor({logger}) {
this.logger = logger;
this.context = Object.assign({}, {global, console, exports, require, module, __filename, __dirname});
}
@ -9,7 +10,7 @@ class RunCode {
try {
return vm.runInNewContext(code, this.context);
} catch(e) {
console.error(e.message);
this.logger.error(e.message);
}
}