From 19a0889d8b7f4e7818752844e154c78ea9e4978f Mon Sep 17 00:00:00 2001 From: Tobias Herber <22559657+herber@users.noreply.github.com> Date: Sun, 28 Dec 2025 18:18:46 +0100 Subject: [PATCH] Add better log output --- clients/typescript/package.json | 2 +- service/src/services/workflowRun.ts | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/clients/typescript/package.json b/clients/typescript/package.json index 62040a0..afea8e1 100644 --- a/clients/typescript/package.json +++ b/clients/typescript/package.json @@ -1,6 +1,6 @@ { "name": "@metorial-services/forge-client", - "version": "1.0.0", + "version": "1.0.1", "publishConfig": { "access": "public" }, diff --git a/service/src/services/workflowRun.ts b/service/src/services/workflowRun.ts index 7fb821a..08b7aca 100644 --- a/service/src/services/workflowRun.ts +++ b/service/src/services/workflowRun.ts @@ -166,6 +166,19 @@ class workflowRunServiceImpl { ); } + private presentOutput(lines: string | string[]) { + let array = Array.isArray(lines) ? lines : lines.split('\n'); + + return array.map(line => { + let [ts, message] = JSON.parse(line); + + return { + timestamp: ts, + message + }; + }); + } + async getWorkflowRunOutput(d: { run: WorkflowRun }) { let steps = await db.workflowRunStep.findMany({ where: { runOid: d.run.oid }, @@ -179,7 +192,7 @@ class workflowRunServiceImpl { let output = await storage.getObject(step.outputBucket, step.outputStorageKey); return { step, - output: output.data.toString('utf-8'), + logs: this.presentOutput(output.data.toString('utf-8')), source: 'storage' as const }; } @@ -191,7 +204,7 @@ class workflowRunServiceImpl { return { step, - output: tempOutputs.map(o => o.output).join('\n'), + logs: this.presentOutput(tempOutputs.map(o => o.output)), source: 'temp' as const }; }) @@ -212,7 +225,7 @@ class workflowRunServiceImpl { if (step.outputBucket && step.outputStorageKey) { let output = await storage.getObject(step.outputBucket, step.outputStorageKey); return { - output: output.data.toString('utf-8'), + logs: this.presentOutput(output.data.toString('utf-8')), source: 'storage' as const }; } @@ -223,7 +236,7 @@ class workflowRunServiceImpl { }); return { - output: tempOutputs.map(o => o.output).join('\n'), + logs: this.presentOutput(tempOutputs.map(o => o.output)), source: 'temp' as const }; }