From e6d6e3ac774b43ab1e8f25b4e7ee8d6e1b7850d2 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 12 Nov 2019 15:49:45 -0500 Subject: [PATCH] log coderunner --- packages/core/code-runner/src/index.ts | 9 +++++++++ packages/core/core/src/engine.ts | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/core/code-runner/src/index.ts b/packages/core/code-runner/src/index.ts index 5c626ed02..1f6019843 100644 --- a/packages/core/code-runner/src/index.ts +++ b/packages/core/code-runner/src/index.ts @@ -10,10 +10,14 @@ class CodeRunner { private logger: Logger; private events: Events; private vm: VM; + private logId: any; + private debugLog: any; constructor(embark: Embark, _options: any) { this.logger = embark.logger; this.events = embark.events; + this.logId = embark.logId; + this.debugLog = embark.debugLog; this.vm = new VM({ require: { @@ -53,9 +57,11 @@ class CodeRunner { } private evalCode(code: string, cb: Callback, tolerateError = false, logCode = true, logError = true) { + let logId = this.debugLog.log({parent_id: this.logId, type: "method", name: "evalCode", inputs: {code, cb, tolerateError, logCode, logError}}); cb = cb || (() => { }); if (!code) { + this.debugLog.log({id: logId, outputs: ""}); return cb(null, ""); } @@ -63,13 +69,16 @@ class CodeRunner { if (err) { if (logCode) { this.logger.error(__("Error running code: %s", code)); + this.debugLog.log({id: logId, outputs: err, error: "error running code"}); } if (logError) { this.logger.error(err.toString()); + this.debugLog.log({id: logId, outputs: err, error: err.toString()}); } return cb(err); } + this.debugLog.log({id: logId, outputs: result}); cb(null, result); }); } diff --git a/packages/core/core/src/engine.ts b/packages/core/core/src/engine.ts index a82be6f04..e401a0d0a 100644 --- a/packages/core/core/src/engine.ts +++ b/packages/core/core/src/engine.ts @@ -7,7 +7,7 @@ import { ServicesMonitor } from './services_monitor'; import { normalizeInput } from 'embark-utils'; import { Logger } from 'embark-logger'; -import { DebugLog } from 'embark-structlog'; +import DebugLog from 'embark-structlog'; const EMBARK_PROCESS_NAME = 'embark';