Skip to content

Commit

Permalink
fix(PoGw): filter log output to ensure that message field in JSONL ou…
Browse files Browse the repository at this point in the history
…tput is never an object
  • Loading branch information
jstarpl committed Dec 19, 2024
1 parent d2a3cdf commit 0d2b844
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/live-status-gateway/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
)
Expand Down
10 changes: 10 additions & 0 deletions packages/playout-gateway/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
)
Expand Down

0 comments on commit 0d2b844

Please sign in to comment.