Skip to content

Commit

Permalink
Addition of Container.getAll() method as discussed in #970
Browse files Browse the repository at this point in the history
  • Loading branch information
PratikFandade committed Oct 6, 2024
1 parent 195e55c commit 8627949
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/winston/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,19 @@ module.exports = class Container {
return this.add(id, options);
}

/**
* Retreives all `winston.Logger` instances for the specified `regex`.
* @param {!string} id - The regrex to match the Loggers to get.
* @returns {Map<Logger>} - A Map of Logger instances matching the regex.
*/
getAll(regex) {
if(regex) {

Check failure on line 74 in lib/winston/container.js

View workflow job for this annotation

GitHub Actions / Tests (16)

Expected space(s) after "if"

Check failure on line 74 in lib/winston/container.js

View workflow job for this annotation

GitHub Actions / Tests (18)

Expected space(s) after "if"

Check failure on line 74 in lib/winston/container.js

View workflow job for this annotation

GitHub Actions / Tests (20)

Expected space(s) after "if"
return new Map([...this.loggers].filter(([key]) => key.match(regex)));
}

return this.loggers;
}

/**
* Check if the container has a logger with the id.
* @param {?string} id - The id of the Logger instance to find.
Expand Down

0 comments on commit 8627949

Please sign in to comment.