Skip to content

Commit

Permalink
Merge pull request #51 from Deterus/add-isDebugEnabled-check
Browse files Browse the repository at this point in the history
feat(logging): Allow isDebugEnabled to be returned
  • Loading branch information
EisenbergEffect authored Jun 12, 2018
2 parents 300e74f + 9e7d571 commit 67e68cc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,4 +331,11 @@ export class Logger {
setLevel(level: number): void {
this.level = level;
}

/**
* Returns if the logger is in debug mode or not.
*/
isDebugEnabled(): boolean {
return this.level === logLevel.debug;
}
}
11 changes: 11 additions & 0 deletions test/logging.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,17 @@ describe('The log manager ', () => {
expect(globalLogLevel).toEqual( LogManager.logLevel.debug);
});

it('should be able to tell if the log level is debug', () => {
LogManager.setLevel(LogManager.logLevel.debug);
var isDebugEnabledAtDebugLevel = logger.isDebugEnabled();

LogManager.setLevel(LogManager.logLevel.warn);
var isDebugEnabledAtWarnLevel = logger.isDebugEnabled();

expect(isDebugEnabledAtDebugLevel).toEqual(true);
expect(isDebugEnabledAtWarnLevel).toEqual(false);
});

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

0 comments on commit 67e68cc

Please sign in to comment.