Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition of Logger.getAll() method as discussed in #970 #2515

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
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 @@
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.
DABH marked this conversation as resolved.
Show resolved Hide resolved
* @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"
DABH marked this conversation as resolved.
Show resolved Hide resolved
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
Loading