From 0d2b84451751a859d6a3d67e0f3083c735905578 Mon Sep 17 00:00:00 2001 From: Jan Starzak Date: Thu, 19 Dec 2024 16:11:43 +0100 Subject: [PATCH] fix(PoGw): filter log output to ensure that message field in JSONL output is never an object --- packages/live-status-gateway/src/index.ts | 10 ++++++++++ packages/playout-gateway/src/index.ts | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/packages/live-status-gateway/src/index.ts b/packages/live-status-gateway/src/index.ts index 89094e926c..b5fdb0d900 100644 --- a/packages/live-status-gateway/src/index.ts +++ b/packages/live-status-gateway/src/index.ts @@ -12,6 +12,16 @@ const myFormat = combine( splat(), printf((obj) => { obj.localTimestamp = new Date().toISOString() + // Prevent errors and other objects to be inserted as Objects into message field + if (typeof obj.message === 'object') { + if (obj.message instanceof Error) { + const errorObj = obj.message + obj.message = errorObj.message + obj.details = errorObj + } else { + obj.message = JSON.stringify(obj.message) + } + } return JSON.stringify(obj) // make single line }) ) diff --git a/packages/playout-gateway/src/index.ts b/packages/playout-gateway/src/index.ts index b47a3baaac..1f6d955d42 100644 --- a/packages/playout-gateway/src/index.ts +++ b/packages/playout-gateway/src/index.ts @@ -12,6 +12,16 @@ const myFormat = combine( splat(), printf((obj) => { obj.localTimestamp = new Date().toISOString() + // Prevent errors and other objects to be inserted as Objects into message field + if (typeof obj.message === 'object') { + if (obj.message instanceof Error) { + const errorObj = obj.message + obj.message = errorObj.message + obj.details = errorObj + } else { + obj.message = JSON.stringify(obj.message) + } + } return JSON.stringify(obj) // make single line }) )