Skip to content

Commit

Permalink
Merge pull request #114 from iabw/addGetLoggers
Browse files Browse the repository at this point in the history
Add getLoggers method and save name of loggers on instance
  • Loading branch information
pimterry committed Nov 13, 2017
2 parents 2cd93e8 + 3c7bc8c commit 8ac6bf6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Expand Up @@ -199,6 +199,9 @@ The loglevel API is extremely minimal. All methods are available on the root log

Likewise, loggers will inherit the root logger’s `methodFactory`. After creation, each logger can have its `methodFactory` independently set. See the *plugins* section below for more about `methodFactory`.

* A `log.getLoggers()` method.

This will return you the dictionary of all loggers created with `getLogger`, keyed off of their names.

## Plugins

Expand Down
6 changes: 6 additions & 0 deletions lib/loglevel.js
Expand Up @@ -158,6 +158,8 @@
*
*/

self.name = name;

self.levels = { "TRACE": 0, "DEBUG": 1, "INFO": 2, "WARN": 3,
"ERROR": 4, "SILENT": 5};

Expand Down Expand Up @@ -240,5 +242,9 @@
return defaultLogger;
};

defaultLogger.getLoggers = function getLoggers() {
return _loggersByName;
};

return defaultLogger;
}));

0 comments on commit 8ac6bf6

Please sign in to comment.