Skip to content

Commit

Permalink
feat(logging): Allow global logLevel to be returned
Browse files Browse the repository at this point in the history
With [this commit](ec9af2a), it became possible to set the global logLevel through the `setLevel` function. You could however, not retrieve this level unless you created a logger. This PR adds a function `getLevel` that simply returns the global logLevel.
  • Loading branch information
ErikSchierboom authored and Erik Schierboom committed Nov 10, 2016
1 parent 4c1c91c commit 1c61077
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,15 @@ export function setLevel(level: number): void {
}
}

/**
* Gets the level of logging of ALL the application loggers.
*
* @return The logLevel value used in all loggers.
*/
export function getLevel(): number {
return globalDefaultLevel;
}

/**
* A logger logs messages to a set of appenders, depending on the log level that is set.
*/
Expand Down
7 changes: 7 additions & 0 deletions test/logging.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ describe('The log manager ', () => {
expect(attemptingToNewUpALogger).toThrow();
});

it('should be able to return the global logLevel', () => {
LogManager.setLevel(LogManager.logLevel.debug);
var globalLogLevel = LogManager.getLevel();

expect(globalLogLevel).toEqual( LogManager.logLevel.debug);
});

describe('setting logLevel per individual logger instance', () =>
{
it('should not log if specific logger logLevel is none', () => {
Expand Down

0 comments on commit 1c61077

Please sign in to comment.