Skip to content

Commit

Permalink
fix(server/logging): use structured message template not string forma…
Browse files Browse the repository at this point in the history
…tting (#3619)

- string formatting causes high cardinality of messages in the logging system
  • Loading branch information
iainsproat authored Dec 3, 2024
1 parent 101a0b2 commit a0d2831
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/server/modules/previews/services/management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const getObjectPreviewBufferOrFilepathFactory =
}): GetObjectPreviewBufferOrFilepath =>
async ({ streamId, objectId, angle }) => {
angle = angle || defaultAngle
const boundLogger = logger.child({ streamId, objectId, angle })

if (process.env.DISABLE_PREVIEWS) {
return {
Expand Down Expand Up @@ -57,8 +58,8 @@ export const getObjectPreviewBufferOrFilepathFactory =

const previewImgId = previewInfo.preview[angle]
if (!previewImgId) {
logger.warn(
`Preview angle '${angle}' not found for object ${streamId}:${objectId}`
boundLogger.warn(
"Preview angle '{angle}' not found for object {streamId}:{objectId}"
)
return {
type: 'file',
Expand All @@ -69,7 +70,10 @@ export const getObjectPreviewBufferOrFilepathFactory =
}
const previewImg = await deps.getPreviewImage({ previewId: previewImgId })
if (!previewImg) {
logger.warn(`Preview image not found: ${previewImgId}`)
boundLogger.warn(
{ previewImageId: previewImgId },
'Preview image not found: {previewImageId}'
)
return {
type: 'file',
file: previewErrorImage,
Expand Down

0 comments on commit a0d2831

Please sign in to comment.