Skip to content

Commit

Permalink
Prioritize namespace tags on top of global tags (#6122)
Browse files Browse the repository at this point in the history
  • Loading branch information
amitgoldarb committed Jun 27, 2024
1 parent ec919e5 commit f5121c1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/logging/src/internal/pino.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ export const loggerRepo = (
We must "normalize" logTags because there are types of tags that pino doesn't support
for example - Functions.
*/
const normalizedLogTags = normalizeLogTags({ ...namespaceTags, ...global.globalLogTags })
const normalizedLogTags = normalizeLogTags({ ...global.globalLogTags, ...namespaceTags })
const [formattedOrError, unconsumedArgs] =
typeof message === 'string' ? formatMessage(message, ...args) : [message, args]

Expand Down
3 changes: 2 additions & 1 deletion packages/logging/test/internal/pino_logger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ describe('pino based logger', () => {
initialConfig.globalTags = logTags
logger = createLogger()
logger.assignGlobalTags({ newTag: 'data', superNewTag: 'tag', functionTag: () => 5 })
logger.assignTags({ newTag: 'overridden' })
await logLine({ level: 'warn' })
})
it('should contain old tags', () => {
Expand All @@ -406,7 +407,7 @@ describe('pino based logger', () => {
expect(line).toContain('hello { world: true }')
})
it('should contain new logTags also', async () => {
expect(line).toContain('newTag="data"')
expect(line).toContain('newTag="overridden"')
expect(line).toContain('functionTag=5')
expect(line).toContain('superNewTag="tag"')
})
Expand Down

0 comments on commit f5121c1

Please sign in to comment.