Skip to content

Commit 4e6de93

Browse files
committed
remove removeTemporaryLogAttributes, refactor removeKeys
1 parent b7d14ee commit 4e6de93

File tree

1 file changed

+11
-22
lines changed

1 file changed

+11
-22
lines changed

packages/logger/src/Logger.ts

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -511,42 +511,31 @@ class Logger extends Utility implements LoggerInterface {
511511
}
512512

513513
/**
514-
* Alias for removePersistentLogAttributes.
514+
* It removes attributes based on provided keys to all log items generated by this Logger instance.
515515
*
516516
* @param {string[]} keys
517517
* @returns {void}
518518
*/
519519
public removeKeys(keys: string[]): void {
520-
this.removePersistentLogAttributes(keys);
521-
this.removeTemporaryLogAttributes(keys);
522-
}
523-
524-
/**
525-
* It removes persistent attributes based on provided keys to all log items generated by this Logger instance.
526-
*
527-
* @param {string[]} keys
528-
* @returns {void}
529-
*/
530-
public removePersistentLogAttributes(keys: string[]): void {
531-
for (const key of keys) {
532-
if (this.persistentLogAttributes && key in this.persistentLogAttributes) {
533-
delete this.persistentLogAttributes[key];
520+
const removeKey = (attributes: LogAttributes, key: string): void => {
521+
if (attributes && key in attributes) {
522+
delete attributes[key];
534523
}
524+
};
525+
for (const key of keys) {
526+
removeKey(this.persistentLogAttributes, key);
527+
removeKey(this.temporaryLogAttributes, key);
535528
}
536529
}
537530

538531
/**
539-
* It removes temporary attributes based on provided keys to all log items generated by this Logger instance.
532+
* Alias for removeKeys().
540533
*
541534
* @param {string[]} keys
542535
* @returns {void}
543536
*/
544-
public removeTemporaryLogAttributes(keys: string[]): void {
545-
for (const key of keys) {
546-
if (this.temporaryLogAttributes && key in this.temporaryLogAttributes) {
547-
delete this.temporaryLogAttributes[key];
548-
}
549-
}
537+
public removePersistentLogAttributes(keys: string[]): void {
538+
this.removeKeys(keys);
550539
}
551540

552541
/**

0 commit comments

Comments
 (0)