Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/logger/src/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1291,7 +1291,12 @@ class Logger extends Utility implements LoggerInterface {
correlationIdSearchFn,
} = options;

if (persistentLogAttributes && persistentKeys) {
if (
persistentLogAttributes &&
Object.keys(persistentLogAttributes).length > 0 &&
persistentKeys &&
Object.keys(persistentKeys).length > 0
) {
this.warn(
'Both persistentLogAttributes and persistentKeys options were provided. Using persistentKeys as persistentLogAttributes is deprecated and will be removed in future releases'
);
Expand Down
9 changes: 9 additions & 0 deletions packages/logger/tests/unit/workingWithkeys.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,15 @@ describe('Working with keys', () => {
);
});

it('should pass persistentKeys to child with no warning', () => {
// Prepare
const logger = new Logger();
logger.createChild({ persistentKeys: { abc: 'xyz' } });

// Assess
expect(console.warn).toHaveBeenCalledTimes(0);
});

it("doesn't overwrite standard keys when appending keys", () => {
// Prepare
const logger = new Logger();
Expand Down
Loading