Skip to content

Commit 92ba36c

Browse files
authored
feat: Expose additional console methods to workflow context (#831)
1 parent 5ebcb22 commit 92ba36c

File tree

1 file changed

+18
-2
lines changed
  • packages/worker/src/workflow

1 file changed

+18
-2
lines changed

packages/worker/src/workflow/vm.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,17 +176,33 @@ export class VMWorkflowCreator implements WorkflowCreator {
176176
}
177177

178178
/**
179-
* Inject console.log into the Workflow isolate context.
179+
* Inject console.log and friends into the Workflow isolate context.
180180
*
181181
* Overridable for test purposes.
182182
*/
183183
protected injectConsole(context: vm.Context, info: WorkflowInfo, ac: ActivationContext): void {
184+
// isReplaying is mutated by the Workflow class on activation
184185
context.console = {
185186
log: (...args: any[]) => {
186-
// isReplaying is mutated by the Workflow class on activation
187187
if (ac.isReplaying) return;
188188
console.log(`[${info.workflowType}(${info.workflowId})]`, ...args);
189189
},
190+
error: (...args: any[]) => {
191+
if (ac.isReplaying) return;
192+
console.error(`[${info.workflowType}(${info.workflowId})]`, ...args);
193+
},
194+
warn: (...args: any[]) => {
195+
if (ac.isReplaying) return;
196+
console.warn(`[${info.workflowType}(${info.workflowId})]`, ...args);
197+
},
198+
info: (...args: any[]) => {
199+
if (ac.isReplaying) return;
200+
console.info(`[${info.workflowType}(${info.workflowId})]`, ...args);
201+
},
202+
debug: (...args: any[]) => {
203+
if (ac.isReplaying) return;
204+
console.debug(`[${info.workflowType}(${info.workflowId})]`, ...args);
205+
},
190206
};
191207
}
192208

0 commit comments

Comments
 (0)