Skip to content

Commit 0d2b844

Browse files
committed
fix(PoGw): filter log output to ensure that message field in JSONL output is never an object
1 parent d2a3cdf commit 0d2b844

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

packages/live-status-gateway/src/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ const myFormat = combine(
1212
splat(),
1313
printf((obj) => {
1414
obj.localTimestamp = new Date().toISOString()
15+
// Prevent errors and other objects to be inserted as Objects into message field
16+
if (typeof obj.message === 'object') {
17+
if (obj.message instanceof Error) {
18+
const errorObj = obj.message
19+
obj.message = errorObj.message
20+
obj.details = errorObj
21+
} else {
22+
obj.message = JSON.stringify(obj.message)
23+
}
24+
}
1525
return JSON.stringify(obj) // make single line
1626
})
1727
)

packages/playout-gateway/src/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ const myFormat = combine(
1212
splat(),
1313
printf((obj) => {
1414
obj.localTimestamp = new Date().toISOString()
15+
// Prevent errors and other objects to be inserted as Objects into message field
16+
if (typeof obj.message === 'object') {
17+
if (obj.message instanceof Error) {
18+
const errorObj = obj.message
19+
obj.message = errorObj.message
20+
obj.details = errorObj
21+
} else {
22+
obj.message = JSON.stringify(obj.message)
23+
}
24+
}
1525
return JSON.stringify(obj) // make single line
1626
})
1727
)

0 commit comments

Comments
 (0)